-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[HOLD for payment 2023-02-10] File name with "/" removes the extension and breaks the file when downloaded #14266
Comments
Job added to Upwork: https://www.upwork.com/jobs/~01b3bd35954214a174 |
Triggered auto assignment to Contributor Plus for review of internal employee PR - @mananjadhav ( |
Triggered auto assignment to @dangrous ( |
@dangrous i think it could have solution in both, but ideally we would make sure this is processed fine in the backend (havnet looked into where is the root cause of this) |
bump @dangrous 👋 |
Hi sorry - was OOO yesterday! Will look into this today. |
Okay so figured out part of it - When a user uploads an attachment, we sanitize the filename. This would turn, for example, The However, after that point I've confirmed that the filetype is correct, so I'm not sure why it's downloading as png.txt. But either way, if we allow colons in the filename, the behavior is resolved. It downloads as |
@dangrous I think one reason for not using |
I cant really confidently answer if this opens door for some other issues. I would say we could also not allow the But as Manan mentioned, I think converting it to underscore and running with that should be fine if we want just backend solution |
So at some point in the flow (I'm not sure where yet) the Then, the After changing the regex in testing to allow So maybe if I can find where |
There's a lot of somewheres. So are we saying this could purely be external? with no change on the backend? |
I think we should do this in both, change the |
That's fair. So I can put up a PR that adjusts https://github.com/Expensify/Web-Expensify/blob/62f13038a4fe5e3f9991f1d2b23e7a00474a1827/lib/ReportUtils.php#L2221-L2224 to also replace any For reference, I know it's getting switched to a |
I think the and then when we get the file from the backend, we don't get any
Notice the |
Ah okay. So we'd need to add something there to switch it to a When I replace the regex on the backend to swap out |
@mananjadhav is right - that's an old tale in MacOS world since before some old version MacOS used : instead of slashes and some layers of MacOS still use :, some layers use slash - Finder allows slashes to be used in filenames, while some other layers do not use slashes and replace them with : . |
Proposal If we want to replace the file name at the client, we should replace the name during the upload. I think we should replace both the In App/src/components/AttachmentPicker/index.js Lines 33 to 40 in 5370c36
We need to use regex because if we have multiple consecutive colon or slash, we should replace with single underscore. I think we should be doing this only with index.js, but if it needs to be done for the native too, I can do that. Update for the native is: In App/src/components/AttachmentPicker/index.native.js Lines 150 to 155 in 5370c36
|
@dangrous @mananjadhav @akshayasalvi Associated PR seems to raise a regression where we won't able to reach out to Avatar Crop part and the infinite loader will remain on the screen after cleaning the filename. App/src/components/AttachmentPicker/index.js Lines 39 to 42 in 51f1a77
Screen.Recording.2023-02-03.at.6.39.27.PM.mp4To solve we need to make an order change diff --git a/src/components/AttachmentPicker/index.js b/src/components/AttachmentPicker/index.js
index dddceb7cf7..dc6573e02c 100644
--- a/src/components/AttachmentPicker/index.js
+++ b/src/components/AttachmentPicker/index.js
@@ -36,10 +36,10 @@ class AttachmentPicker extends React.Component {
if (file) {
const cleanName = FileUtils.cleanFileName(file.name);
- file.uri = URL.createObjectURL(file);
if (file.name !== cleanName) {
file = new File([file], cleanName);
}
+ file.uri = URL.createObjectURL(file);
this.onPicked(file); Screen.Recording.2023-02-03.at.6.39.48.PM.movContext for me - #14757 |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
Re regression - yes, it looks like this did cause a regression, based on @Pujan92's analysis. I also tried reverting the change locally and confirmed that behavior was correct prior to the change. I'm not sure if a checklist change is needed; I think the thing that was missed here was honestly just proofreading - I should have noticed that the file would no longer have the uri if the name was changed. I guess technically we could have noticed the bug by testing all places where attachments were uploaded, rather than just as attachments - but I'm not sure that's the primary solution here. |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.2.64-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2023-02-10. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
@dangrous I just went through the comments. I didn't think upload Avatar will be any different as it is the same picker. I can see another PR is merged, is there any action pending here for me? |
Hey @akshayasalvi so to clarify (this is confusing!) the step on the checklist above is actually to propose a regression test for the original bug - that is, that Does that make sense? |
Separately, @mananjadhav, I think this is likely just an edge case we didn't consider before, rather than a regression. The initial renaming looks like it was added 7/24/20 into the backend so it was quite some time ago (possibly before the App existed?). Therefore no PR to comment on, and I don't think we need the discussion, as long as we get the new regression test. Does that sound right to you? |
Bump @akshayasalvi and @mananjadhav on the above - thanks! |
Regression Test Proposal Bug: File name with special characters like "/" breaks the file download Proposed Test Steps:
@dangrous @mananjadhav Is this okay for the test proposal? |
I was OOO and just getting back. @akshayasalvi this looks fine, sorry I just saw your comment.
Yes @dangrous. Let's confirm the test proposal and then we should be good. |
Hi @akshayasalvi this looks great! A couple edits - primarily I think we should just be very specific (you're right that it doesn't actually matter the kind of file, etc. but it'll be easier to test if it's particular).
How does that sound? |
@mananjadhav @akshayasalvi @oesayan - can you three please apply to the job so I can issue payment? https://www.upwork.com/jobs/~01b3bd35954214a174 |
@NicMendonca applied, thank you. @dangrous Yes this sounds good. It's my first time writing the regression test proposal. thank you for the help. |
@NicMendonca I've applied too. |
@NicMendonca and I have applied too 🤠 |
@mananjadhav @akshayasalvi - paid, thank you! @oesayan - I'll issue payment once you accept the offer, thanks! |
everyone had been paid! thank you!! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
Valid file downloaded
Actual Result:
Malformed file downloaded due to removed extension
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.2.53-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:
video.mov
Recording.54.mp4
Expensify/Expensify Issue URL:
Issue reported by: @oesayan
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1673509312939899
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: