Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File names with spaces in them seem to break s3 URL #6

Open
joehoyle opened this issue Aug 26, 2014 · 3 comments
Open

File names with spaces in them seem to break s3 URL #6

joehoyle opened this issue Aug 26, 2014 · 3 comments

Comments

@joehoyle
Copy link
Member

If I upload the image: Logo-De-overburen-wit+payoff.png (space in the name as +). This builds the URL:

http://hmn-uploads.s3.amazonaws.com/ht/uploads/sites/3449/2014/02/Logo-De-overburen-wit+payoff.png

This 404s, it needs to be encoded as http://hmn-uploads.s3.amazonaws.com/ht/uploads/sites/3449/2014/02/Logo-De-overburen-wit%2Bpayoff.png

@wkw
Copy link

wkw commented May 21, 2015

so plus symbols should probably just be converted to underscore it sounds like. the code below is what we add to every project to force lowercase filenames (causes problems with our git repos on Mac OS when clients upload files with same names, different capitalization). Should be the proper hook though to do further manipulation:

function my_sanitize_media_names($filename) {
    $info = pathinfo($filename);
    $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
    $name = basename($filename, $ext);
    return strtolower($name) . $ext;
}
add_filter('sanitize_file_name', 'my_sanitize_media_names', 10);

@joehoyle
Copy link
Member Author

Another example: uploads/sites/2/2015/08/foki-då-och-nu.jpg should get some unit tests for this now.

@fklein-lu
Copy link
Contributor

@joehoyle On my test install I created a post and added images with these two problematic names using "Add Media" button. I could not reproduce the issue.

Could you please verify whether this issue is still valid, and if so, provide a path to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants