-
Notifications
You must be signed in to change notification settings - Fork 0
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
Replace reserved chars in filenames #138
Replace reserved chars in filenames #138
Conversation
As the tus endpoint breaks with 400 when uploading files with certain characters within them, the fileName is cleaned from those malfunctioning characters before adding it to the Uppy store (and eventually uploading them, as auto resume is activated). The characters to be replaced were chosen based on a manual test that i conducted - while i could not produce a file containing a forward slash on my linux machine, all other characters have proven to break the endpoint. Maybe i missed a character, then it will have to be added to the list. The fix revealed another bug - file names containing a colon : now broke the frontend, because the colon is used as a separator in getFileInfo. As the conversion (from object to fileString and vice versa) is not needed but is a remainder from the Uppy refactoring (as far as i could understand it), it is dropped altogether, and the file object is directly passed into DpUploadFile.
/* | ||
* For reasons i could not figure out, the for loop was needed here | ||
* to reliably access the item that is looped over. When using forEach, | ||
* strangely it always held the value of currentFile. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since its totally fine to use a for-loop, I suggest to drop the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but in case somebody wants to optimize it, they'll be warned, if we leave the comment there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am against that. Then we have to argue all our code in comments....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, removed in 5c6ee11
Ticket: https://yaits.demos-deutschland.de/T31971
As the tus endpoint breaks with 400 when uploading files with certain characters within them, the fileName is cleaned from those malfunctioning characters before adding it to the Uppy store (and eventually uploading them, as auto resume is activated).
The characters to be replaced were chosen based on a manual test that i conducted - while i could not produce a file containing a forward slash on my linux machine, all other characters have proven to break the endpoint. Maybe i missed a character, then it will have to be added to the list.
The fix actually only changes the file name in the outermost
file.name
, and withinfile.meta.name
, whereas it leaves the original file name withindata.File.name
(which is an instance of the File API and also preserves the original name within its prototype). Somehow this leads to the unchanged file name being displayed correctly after uploading has finished. As such, there can be said that the bug has not been understood from a backend perspective.The fix revealed another bug - file names containing a colon : now broke the frontend, because the colon is used as a separator in getFileInfo. As the conversion (from object to fileString and vice versa) is not needed but is a remainder from the Uppy refactoring (as far as i could understand it), it is dropped altogether, and the file object is directly passed into DpUploadFile.