Project

General

Profile

Actions

Bug #5246

closed

UTF8 image filename breaks avatar image uploading

Added by nant over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
22 April 2015
Due date:
% Done:

100%

Estimated time:

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

Actions #1

Updated by krileon over 9 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.

Actions #2

Updated by krileon over 9 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.

Actions #3

Updated by krileon over 9 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.

Actions #4

Updated by krileon over 9 years ago

  • Status changed from Feedback to Resolved
  • % Done changed from 0 to 100

Fixed in MR !858

Actions #5

Updated by beat over 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF