[wp-trac] Re: [WordPress Trac] #6294: Uploading media file with same sanitized filename as existing file will overwrite existing file.

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 20 09:07:08 GMT 2008


#6294: Uploading media file with same sanitized filename as existing file will
overwrite existing file.
-------------------------------------+--------------------------------------
 Reporter:  markjaquith              |        Owner:  neodude 
     Type:  defect                   |       Status:  assigned
 Priority:  highest omg bbq          |    Milestone:  2.5     
Component:  Administration           |      Version:  2.5     
 Severity:  blocker                  |   Resolution:          
 Keywords:  has-patch needs-testing  |  
-------------------------------------+--------------------------------------
Changes (by neodude):

 * cc: neodude (added)
  * keywords:  => has-patch needs-testing

Comment:

 '''functions.php-r7414.diff''' fixes:
  - edge case: failed to handle a file named '.ext'
  - sanitize_title_with_dashes called too late, which is, AFAIK, the cause
 of this bug
  - with s_t_w_d moved up, the # and \ checks are redundant, since s_t_w_d
 does s/[^^%a-z0-9 _-]// anyway

 I tested two different files named ''test%test.png'' and
 ''test%%test.png'', which correctly gives ''testtest.png'' and
 ''testtest1.png'' respectively.

 The unit tests cover pretty much all of wp_unique_filename, but only
 vaguely common bits of sanitize_title_with_dashes. The latter function is
 very complex to write test cases completely for, so I thought I'd save my
 time.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6294#comment:2>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list