#7484 closed defect (bug) (fixed)
Resize member avatar error with cyrillic (not latin) filename
Reported by: | snookerist | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | 2.3.0 |
Component: | Core | Keywords: | has-patch |
Cc: |
Description
When user upload user avatar the system offers to resize image.
If uploaded image filename contains cyrillic (not latin) characters, then appears error, meaning that error was occured on image resizing (При изменении размеров вашей картинки профиля произошла ошибка.).
If user upload image with filename containing only latic characters (not cyrillic) operation be done successfull.
I use the last version of WordPress and BuddyPress.
System language is russian.
Attachments (2)
Change History (13)
#1
@
7 years ago
This ticket was mentioned in Slack in #buddypress by hnla. View the logs.
7 years ago
#3
@
7 years ago
- Keywords has-patch added
- Version changed from 2.8.2 to 2.3.0
The problem is mostly with WordPress not properly converting utf-8 filenames to an ASCII version.
See #WP22363, #WP24661, #WP15955.
We can wait for WordPress to fix this or we can put in a temporary fix.
iconv.patch
will try to convert any utf-8 characters in the filename to their ASCII equivalent. This should fix the immediate issue with our uploader class, but relies on iconv
, which might not be available and is a little finicky depending on the system.
Could try using mb_convert_encoding()
as well. Or if remove_accents()
worked properly, we could do the following:
add_filter( 'sanitize_file_name', 'remove_accents' );
An alternative method would be using URLify against our filenames:
https://github.com/jbroadway/urlify#usage
But that will require adding another external library.
#4
@
7 years ago
Given your comments above & that this is really a root issue in WP...
<snip> but relies on iconv
As it's an extension to PHP & as you say which might not be available I think that rules this out as a fix?
mb_convert_encoding()
possibly?
Adding an external library sounds like a bad idea given that WP ought to/will fix at some point.
If this causes issues for WP sites in general then we are fixing sites for images in one small respect while leaving the wider issue existing which seems odd to me, the sites are broken for images regardless of what we do?
I find this an odd issue given WP places importance on internationalization yet that last ticket is years old!
I am proposing we close this as a 'wontfix', r-a-y you prompted on the WP ticket and I think we need to leave it there but I leave that decision to you :)
#5
@
7 years ago
WordPress uses iconv()
in one of their functions, wp_check_invalid_utf8()
:
https://github.com/WordPress/WordPress/blob/4.7-branch/wp-includes/formatting.php#L1062
I think it's safe for us to use it as well, since we should support all languages as much as possible until WordPress offers better support for transliteration in remove_accents()
:
https://github.com/WordPress/WordPress/blob/4.7-branch/wp-includes/formatting.php#L1513
#6
@
7 years ago
- Milestone changed from Awaiting Review to Under Consideration
01.patch
makes use of a PHP 5.4 function called transliterator_transliterate()
if available. That function also works if the PECL intl
is installed.
If not available, we use WP's remove_accents()
, which covers quite a few languages, but not all like Cyrillic. After that, if the filename still has some utf8 characters, we use iconv()
if it exists.
Hello, I also have this problem. Please help me solve it.
WordPress 4.7.4 , BuddyPress 2.8.2