Bug #5246
closedUTF8 image filename breaks avatar image uploading
Description
As reported here:
https://www.joomlapolis.com/forum/147-potential-bug/229436-avatar-profile-picture-doesnt-save-with-cyrillic-letters
I tested to upload an image file named ελληνικά.jpg and I get:
Error
Profile image : Please select a image file before uploading
Updated by krileon almost 10 years ago
This is due to the processing done on filenames to clean them of possible invalid characters. This is done as follows.
preg_replace( '/[^-a-zA-Z0-9_]/', '', pathinfo( $value['name'], PATHINFO_FILENAME ) )
The problem is this won't work with UTF8 characters. The only way to force it to work is to use the u modifier and replace a-zA-Z0-9 with \w. The problem with that is the u modifier is extremely strict. Any partial UTF8 characters will cause it to silently fail. PCRE also needs to be compiled with UTF8 support or it throws a warning. Doesn't seam like a safe solution.
Updated by krileon almost 10 years ago
- Status changed from Assigned to Feedback
- Assignee changed from krileon to beat
Joomla also doesn't appear to account for utf8 in its preg_replace usages as well. Especially filenames. This seams like a "do not fix" type bug. It's also possible UTF8 characters in a filename could be an issue depending on the OS of the server.
Updated by krileon almost 10 years ago
Another option is a helper function that calls mb_ereg_replace when available otherwise call preg_replace then this would work. Similar to our other helper functions (e.g. cbutf8_preg_replace). This isn't a 1:1 solution though as mb_ereg_replace doesn't use delimiters so a helper function to call either/or probably wouldn't work very well.
Updated by krileon almost 10 years ago
- Status changed from Feedback to Resolved
- % Done changed from 0 to 100
Fixed in MR !858