Opened 2 months ago
Last modified 8 weeks ago
#66125 assigned defect (bug)
Upload file with double-quote in filename
| Reported by: | sgastard | Owned by: | sgastard |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Upload | Version: | 7.1 |
| Severity: | normal | Keywords: | has-patch changes-requested |
| Cc: | Focuses: |
Description
Uploading a file like "test".png results in a filename like 22test22.png on the server and a matching URL. The file remains accessible.
Attachments (1)
Change History (8)
This ticket was mentioned in PR #13574 on WordPress/wordpress-develop by @sgastard.
2 months ago
#1
- Keywords has-patch added
This ticket was mentioned in PR #13575 on WordPress/wordpress-develop by @sgastard.
2 months ago
#2
Opened from the WordPress Contributor Toolkit.
This ticket was mentioned in PR #13579 on WordPress/wordpress-develop by @sgastard.
2 months ago
#4
- Keywords has-patch added
Clean filename of uploaded file when the name contains quote (")
#7
@
8 weeks ago
- Keywords changes-requested added
Re-sharing my PR review here for visibility:
I wonder if
sanitize_file_name()is the best location to do these replacements. What if I have a image that depicts the modulo operator in PHP. I create an illustration:220 % 22 = 0. The file name I use is220%22.png. With the changes here, this will become220.png, which is not helpful.
I think the URL decoding is being done at the wrong layer. The decoding should be done at a layer above at the point where we _know_ the filename _is_ URL encoded.
In that way, if I have a URL-encoded filename for the above example, it is
220%2522.pngand it should be decoded into220%22.pngand this should pass-through to be used as the file name. Or else, if%is not a permitted character, then at this point it can be replaced with-ormodor something else which is safe for the filesystem.
Opened from the WordPress Contributor Toolkit.