[wp-trac] [WordPress Trac] #50855: sanitize_file_name function not working as expected if there is '%20' in filename

WordPress Trac noreply at wordpress.org
Wed Aug 5 08:00:11 UTC 2020


#50855: sanitize_file_name function not working as expected if there is '%20' in
filename
--------------------------+-----------------------------
 Reporter:  dishitpala    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Formatting    |    Version:  5.4.2
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 We have added '%' as a special character in `$special_char` variable
 We are also replacing '%20' with '-'

 Here the sequence of str_replace was not appropriate

 We need to replace '%20' with '-' before all the special character are
 replaced

 Current behavior:
 - Filename Before: `this%20is%20example.png`
 - Filename after sanitization: `this20is20example.png`

 Expected behavior:
 - Filename Before: `this%20is%20example.png`
 - Filename after sanitization: `this-is-example.png`

 File reference: https://github.com/WordPress/WordPress/blob/master/wp-
 includes/formatting.php

 Function name: sanitize_file_name

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50855>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list