Replace file names with underscore when they have slash /#14664
Conversation
|
@dangrous @mananjadhav One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@dangrous @mananjadhav I tried hard but I don't think Android allows : and / in the file name. I tried downloading a new file, renaming the file locally hence I've just tested with an current test image. |
| * @returns {String} | ||
| */ | ||
| function cleanFileName(fileName) { | ||
| return fileName.replace(/[^a-zA-Z0-9\-\\._]+/g, '_'); |
There was a problem hiding this comment.
Quick comment before going through the full review, right now this has an extra \ before the . so wouldn't catch the right characters. Let's also remove the + here as noted in #14266 (comment)
| return fileName.replace(/[^a-zA-Z0-9\-\\._]+/g, '_'); | |
| return fileName.replace(/[^a-zA-Z0-9\-\._]/g, '_'); |
There was a problem hiding this comment.
@dangrous I added \\ to ignore the \ as well. But yeah it makes sense to remove that. I've updated the regex. Can you check now?
Reviewer Checklist
Screenshots/VideosWebweb-clean-file-name.movMobile Web - Chromemweb-chrome-clean-file-name.movMobile Web - Safarimweb-safari-clean-file-name.movDesktopdesktop-clean-file-name.moviOSios-clean-file-name.movAndroidandroid-clean-file-name.mov@dangrous All yours. The change works fine. I've checked the |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/dangrous in version: 1.2.64-0 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.64-7 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.64-7 🚀
|
1 similar comment
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.64-7 🚀
|
| if (file.name !== cleanName) { | ||
| file = new File([file], cleanName); | ||
| } |
There was a problem hiding this comment.
We should have included the filetype to prevent this bug . The bug arises after a backend change aimed at validating files by their types.
Details
Our file uploads, have issues when we have
/or:, because these characters were stripped and the files are saved with.png, etc. typesFixed Issues
$ #14266
PROPOSAL: #14266 (comment)
Tests
:or/with the extension, for example,/.png.:and/replaced with_:,/, characters, it should replace with the equal number of underscores(_) in the filename.Offline tests
QA Steps
:or/with the extension, for example,/.png.:and/replaced with_:,/, characters, it should replace with the equal number of underscores(_) in the filename.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.Screenshots/Videos
Web
screen-recording-2023-01-30-at-114858-pm_aqjpeCtC.mp4
Mobile Web - Chrome
Screen.Recording.2023-01-31.at.1.19.45.AM.mov
Mobile Web - Safari
screen-recording-2023-01-31-at-125458-am_4cWC02fr.mp4
Desktop
screen-recording-2023-01-30-at-115256-pm_w55iSb78.mp4
iOS
screen-recording-2023-01-31-at-124421-am_cVByvJPq.mp4
Android
Screen.Recording.2023-01-31.at.1.20.49.AM.mov