#24117 closed defect (bug) (duplicate)
Multisite installations using ms-files.php rewriting can't handle uploaded files with plus sign (+) in the file name
Reported by: | jamescollins | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Multisite | Keywords: | has-patch |
Focuses: | Cc: |
Description
On a WordPress Multisite network that uses ms-files.php rewriting, if you upload a file with a plus sign in the file name then the file isn't accessible via the default /files/
URL.
Steps to reproduce:
On a Multisite installation that was set up prior to WP 3.5), upload a file with a plus sign in the file name (eg file name here+.pdf
), WordPress renames the file to file-name-here+.pdf
.
The file's URL is then:
http://domain.com/files/file-name-here+.pdf
However loading that URL results in a 404 error.
However manually requesting the file via the non-pretty URL (ie not going via ms-files.php) does work:
http://domain.com/wp-content/blogs/dir/1/file-name-here+.pdf
ms-files.php attempts to locate this file:
/path/to/wordpress/wp-content/blogs.dir/1/files/file-name-here .pdf
which doesn't exist, because the file on the filesystem still has the plus sign in the name (/path/to/wordpress/wp-content/blogs.dir/1/files/file-name-here+.pdf
.
I think WordPress' sanitize_file_name()
function should automatically remove the +
character from file names during the upload process.
24117.diff
automatically removes the plus sign character from file names during the upload process.This solution solves the problem for new files that are uploaded, however it doesn't solve it for existing media library files that contain a plus sign in their name.