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

Certain characters in folder name cause image upload to fail #891

Closed
bassplayer7 opened this issue Dec 12, 2016 · 4 comments
Closed

Certain characters in folder name cause image upload to fail #891

bassplayer7 opened this issue Dec 12, 2016 · 4 comments
Assignees
Labels

Comments

@bassplayer7
Copy link

bassplayer7 commented Dec 12, 2016

Overview

If a ? character is added to Advanced -> Folder Name, it will cause errors to be thrown when uploading images. The images appear after removing the ? from the folder name. It is possible that other characters cause issues as well.

Steps to Reproduce:

  1. Create a modular with a folder name containing a ? along with other alpha-numeric characters.
  2. Save the page and attempt to upload images.
  3. An error appears: move_uploaded_file([path to file *without* a ?]/image.jpg): failed to open stream: No such file or directory
  4. Remove ? from Folder Name
  5. Images upload smoothly.
@flaviocopes
Copy link
Contributor

The problem is ? is a special character. We should disallow changing a folder name (or creating a new one) to contain ? in the first place, as it's going to be interpreted by the browser unless urlencoded. The problem seems linked to the fact you can first save as yourfolder? but then saving a second time, without any other change, the folder is back to yourfolder.

@bassplayer7
Copy link
Author

Obviously someone could set the folder name to include a ? but in this case everything was done through the admin panel. It seemed to me that it shouldn't let any invalid characters be saved.

@flaviocopes
Copy link
Contributor

Yes if we state ? (as with & or other special chars reserved in URIs) are not supported, it should be denied when saving.

@bassplayer7
Copy link
Author

Or, as a possible alternative, what about automatically swapping any unacceptable characters out for - to make it URL friendly. I'm thinking of something like this:

$url = str_replace(' ', '-', strtolower($url));
$url = preg_replace('/[^\da-z\-]/i', '-', $url);
$url = preg_replace('/-+/', '-', $url);
$url = rtrim(ltrim($url, '-'), '-');

The end goal would be to turn My(?) Folder Name! into my-folder-name.

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

No branches or pull requests

3 participants