WordPress.org

Make WordPress Core

Opened 9 months ago

#50855 new defect (bug)

sanitize_file_name function not working as expected if there is '%20' in filename

Reported by: dishitpala Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.4.2
Component: Formatting Keywords: has-patch
Focuses: Cc:

Description

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

Attachments (1)

sanitize-file-name.patch (841 bytes) - added by dishitpala 9 months ago.

Download all attachments as: .zip

Change History (1)

Note: See TracTickets for help on using tickets.