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

Stricter file and folder name validation #6748

Closed
BenedekFarkas opened this issue Apr 12, 2016 · 1 comment · Fixed by #6792
Closed

Stricter file and folder name validation #6748

BenedekFarkas opened this issue Apr 12, 2016 · 1 comment · Fixed by #6792
Assignees
Milestone

Comments

@BenedekFarkas
Copy link
Member

Windows (NTFS) prohibits the use of the following characters in file and folder names: ", *, :, <, >, ?, |, /, \.

Due to the differences in how files are stored in Azure Blob Storage (including the Development Storage of the Storage Emulator) most of these are actually accepted when renaming files in the Media Library when using Microsoft Azure Media Storage:

  • ", <, >, |: Server error when calling the API to query media items ("Illegal characters in path."). For some of the illegal characters, the file name is changed up until the illegal character, but the rest of it is cut off. This error renders the Media Library unusable when opening a folder that contains an affected file.
  • *, :, ?: The file can't be downloaded to the local file system without changing its name (also true for the previous set of characters).
  • /: Creates a folder for each slash in the file name (and displayed as such in the Media Library navigation) and the file is at the bottom of the folder structure created by those slashes, but the file is displayed in the correct folder (where it was actually uploaded) in the Media Library (with a file name that has the folder structure defined by the slashes cut off).
  • \: This is the only illegal character that is handled correctly: A validation error is displayed when saving the file.

Suggestion: Trigger a validation error for all illegal characters.

@MatteoPiovanelli-Laser
Copy link
Contributor

Besides having added a bunch of characters, in #7577 I added a validation to the FileSystemStorageProvider to further prevent invalid characters in the path. Something similar could be done for Azure. It should be straightforward, but I am not volunteering because we don't use Azure storage and I would have no way to test or validate this.

@BenedekFarkas BenedekFarkas changed the title Media Library + Azure: illegal characters causing various problems Stricter file and folder name validation Apr 8, 2024
@BenedekFarkas BenedekFarkas linked a pull request Apr 8, 2024 that will close this issue
BenedekFarkas added a commit that referenced this issue Apr 18, 2024
* Media Library: More strict file and folder name validation, fixes #6748

* Resetting MediaLibraryService changes to 1.10.x

* Code styling in FileSystemStorageProvider

* Adding string file and folder name validation to FileSystemStorageProvider, so that MediaLibrary components don't need to do it separately

* Applying the same file and folder name validation to AzureFileSystem too

* Code styling and fixes in AzureFileSystem, MediaLibrary and IStorageProvider

* Simplifying invalid character detection

* Code styling

* Adding InvalidNameCharacterException to be able to handle invalid characters precisely at various user-facing components

* Updating MediaLibrary not to log an error when a file can't be uploaded due to invalid characters

---------

Co-authored-by: Lombiq <github@lombiq.com>
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

Successfully merging a pull request may close this issue.

3 participants