getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.56k stars 1.41k forks source link

Use of Locale Unsafe functions #2084

Open tcyrus opened 6 years ago

tcyrus commented 6 years ago

basename, dirname, and pathinfo are locale aware, meaning that they will only handle characters that match up with the PHP default locale (ASCII). For example, Using Non-ASCII Unicode filenames for Media files would cause Grav to ignore them, since it used basename for checks (Fixed in #2083). There is a similar issue here with the use of pathinfo (See php.net for more info):

https://github.com/getgrav/grav/blob/cad10b6095bc86fa7610712283f3e88a33dbd2bc/system/src/Grav/Common/Page/Medium/MediumFactory.php#L29

One solution is to make a set of locale safe helper functions. I have made a set of helper functions that can be used as an example here.

rhukster commented 6 years ago

https://github.com/PHPMailer/PHPMailer/blob/5c9d3c548497390822369516691139f0a724b621/src/PHPMailer.php#L4005-L4039

Good idea.. perhaps for 1.5