-
Notifications
You must be signed in to change notification settings - Fork 3k
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 file names with underscore when they have slash /
#14664
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. |
src/libs/fileDownload/FileUtils.js
Outdated
* @returns {String} | ||
*/ | ||
function cleanFileName(fileName) { | ||
return fileName.replace(/[^a-zA-Z0-9\-\\._]+/g, '_'); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
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.
Hurray! Nice work.
✋ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component 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