[wp-trac] [WordPress Trac] #15955: move_uploaded_file mangles non-ascii characters on Windows platforms
WordPress Trac
wp-trac at lists.automattic.com
Tue Feb 1 22:53:07 UTC 2011
#15955: move_uploaded_file mangles non-ascii characters on Windows platforms
-------------------------------------+------------------------------
Reporter: t31os_ | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upload | Version: 3.0.3
Severity: normal | Resolution:
Keywords: has-patch needs-testing |
-------------------------------------+------------------------------
Comment (by SergeyBiryukov):
Took more time to investigate. Actually it's not just some characters and
not just `move_uploaded_file()`. The characters on the screenshots are
perfectly valid on Windows, since NTFS uses UTF-16.
The problem is that on Windows, there's currently no way to tell PHP that
we use UTF-8 in file names. It defaults to single-byte ANSI code page
(Windows-1251, etc.) for console applications. Therefore `abcdef²³.jpg`
becomes `abcdefВІВі.jpg`. Files with Cyrillic names get mangled too:
`Картинка.jpg` becomes `Картинка.jpg`.
The names need to be converted to that ANSI charset not just in
`wp_handle_upload()`, but also in other places like
`wp_generate_attachment_metadata()`, `wp_delete_attachment()`, etc.
As a workaround, I wrote an experimental plugin that leverages current
API.
Tested file uploading, deleting and image editing (the most tricky part)
on the examples from the screenshots.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15955#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list