U4-5139 - Error uploading a file when filename contains comma

Created by Russell 25 Jun 2014, 02:52:46 Updated by Shannon Deminick 04 Aug 2017, 00:07:45

Tags: Up For Grabs PR

I get this error "The specified file type has been disallowed by the administrator" when I tried to upload a pdf file with this name "Finding Nemo - Wikipedia, the free encyclopedia.pdf".

The same file uploads fine when i removed the comma from the name.

1 Attachments

Comments

Mikkel Johansen 07 Jul 2014, 13:34:43

It is not possible upload files with commas in filename. The file-upload returns this error: Validation: [dissallowedMediaType]

If you drag-and-drop the file. It works!


Nicholas Westby 14 Jul 2014, 21:59:42

I was running into this issue too with filenames like "Last,-First-Middle,-M.D..jpg". I get the validation error, but it seems like the image saves fine (though, a second save resulted in a duplicate media item without an image and a "(1)" suffixed).


Dennis Öhman 25 Sep 2014, 08:01:53

Hade the same problem and made a ugly quick fix.

umbraco.controller.js > fileUploadController > on.filesSelected

Replace: newVal += args.files[i].name

With: newVal += args.files[i].name.replace(",","")

"," should not be used as a seperator.


Zac 15 Oct 2014, 16:42:18

Same issue with dashes in the filename. I.E. test-file-information.pdf fails but test_file_information.pdf succeeds


Zac 12 Jun 2015, 14:33:09

Issue still exists in 7.2.5


Tom Fulton 01 Oct 2015, 15:07:28

Hi, I did some debugging on this in 7.3.0, results/questions below:

The validation error occurs in the [https://github.com/umbraco/Umbraco-CMS/blob/7c4a189aa3cf583954defd9c43a3e55e325f2c3f/src/Umbraco.Web/PropertyEditors/UploadFileTypeValidator.cs UploadFileTypeValidator], it tries to [https://github.com/umbraco/Umbraco-CMS/blob/7c4a189aa3cf583954defd9c43a3e55e325f2c3f/src/Umbraco.Web/PropertyEditors/UploadFileTypeValidator.cs#L24 split] the selectedFiles field by ,, thus resulting in the confusion when checking extensions if a filename has a comma itself.

It appears this validator is being called by the ModelBinder, and is only getting hit for the '''Upload''' field - it is not used for the "folder upload control" or the image cropper.

I was wondering why this Split(',') was even necessary, since it's only used by the Upload field which we can assume only has one file (''right?''). I thought it might be for handling multiple upload fields on a page, but testing shows that the Validate method gets called separately for each property with their respective individual values.

There might be an edge case I'm missing though, any ideas why the upload field would need to support multiple files/values? Maybe it was just there for future support, or because the JS API gives you a collection by default? Maybe relevant, the split has been there for [https://github.com/umbraco/Umbraco-CMS/commits/7c4a189aa3cf583954defd9c43a3e55e325f2c3f/src/Umbraco.Web/PropertyEditors/UploadFileTypeValidator.cs 2+ years].

I looked at some other options:

  • '''Split by another character''' - the filenames gets serialized [https://github.com/umbraco/Umbraco-CMS/blob/7c4a189aa3cf583954defd9c43a3e55e325f2c3f/src/Umbraco.Web.UI.Client/src/views/propertyeditors/fileupload/fileupload.controller.js#L113 here], but assuming the field supports multiple values, using another character would change the schema which we probably don't want to do. If the field is not supposed to support multiple values, we can safely change the delimiter — I've done so [https://github.com/tomfulton/Umbraco-CMS/commit/0cedeca01476cdd6687995866d7f1c2fd6fe5262 here] and it seems to work. Can submit as a PR if it's the way to go.

  • '''Remove the Split''' - if the field doesn't truly support multiple values, we can remove the Split in the validator (and maybe change selectedFiles to selectedFile for clarity).

  • '''Replace the comma client side''' - as [Dennis suggested|http://issues.umbraco.org/issue/U4-5139#comment=67-16410], this seems to work too, maybe it's the safest way? Have the code [here|https://github.com/tomfulton/Umbraco-CMS/commit/4cf69d3589ddea082cfb08d569f881fe0438edb2] and can pull request if you like.

Side note - the comma is later stripped out of the filename somewhere else, so that's taken care of :).


Shannon Deminick 26 Jun 2017, 07:15:15

Closing issue due to inactivity - see blog post for details https://umbraco.com/blog/issue-tracker-cleanup/


Jeffrey Schoemaker 16 Jul 2017, 09:52:54

It still is a bug in the latest Umbraco-version 7.6.4.

  1. Rightclick on a media folder and Create new File

  2. Name the media-item something (it can be a name with or without a comma, that doesn't matter)

  3. Upload a file with a comma in it (like "Umbraco, Rocks.pdf").

  4. Save => You will get the attached errormessage "The specified file type has been disallowed by the administrator" (but in Dutch)

  5. The file is uploaded thought and the filename on disk is Umbraco-rocks.pdf, so that is correct. But the error message is quite scary for a editor, and not really necessary

The above does not happen when using the drag-and-drop-upload that you have on a folder, and also doesn't happen when you upload an image with a comma in its filename.

Cheerio,

Jeffrey


Shannon Deminick 17 Jul 2017, 02:49:58

Anyone able to submit a PR for this one?


Alessandro Calzavara 28 Jul 2017, 13:51:12

@Shandem I created a PR https://github.com/umbraco/Umbraco-CMS/pull/2083: I replaced the ',' with '-' instead of simply removing it because that's what was already done server-side.


Alessandro Calzavara 03 Aug 2017, 16:13:42

Sorry, I tried to add the pull request TAG but failed miserably :)


Shannon Deminick 04 Aug 2017, 00:07:45

I can do that :)


Priority: Normal

Type: Bug

State: Open

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted: Pull request

Affected versions: 7.3.0, 7.2.5, 7.2.8, 7.6.0, 7.6.1, 7.6.2, 7.6.3, 7.6.4

Due in version:

Sprint:

Story Points:

Cycle: