[wp-trac] [WordPress Trac] #16330: media_sideload_image() broken with filenames containing strange characters (e.g., +, %)

WordPress Trac wp-trac at lists.automattic.com
Sat Nov 12 12:02:19 UTC 2011


#16330: media_sideload_image() broken with filenames containing strange characters
(e.g., +, %)
-------------------------------------+------------------------------
 Reporter:  Coolkevman               |       Owner:
     Type:  defect (bug)             |      Status:  reopened
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Media                    |     Version:  3.1
 Severity:  major                    |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+------------------------------
Changes (by kawauso):

 * keywords:  needs-patch => has-patch needs-testing


Comment:

 Sanitization is already partly addressed by `sanitize_file_name()`, run as
 part of `wp_unique_filename()` on line 462. It looks like adding `%` and
 `+` to that covers all the test files I've tried, though it will have a
 wider impact as well.

 Attaching patch that adds those characters, decodes sideloaded filenames
 (else you end up with sanitized encoded characters) and removes the two
 `str_replace()` lines which as far as I can tell serve no purpose given
 that `sanitize_file_name()` already removes those characters (see r8192).

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16330#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list