Repository navigation
Conversation
checkFileExists used decodeURI, which leaves reserved characters like # encoded (%23). A receipt shared into the app whose filename contains one (e.g. "Recibo de CASA MIRLO SL. #BEio.pdf") was then looked up by a path that does not match the file on disk, so RNFS.stat reported it missing at upload time. The receipt was dropped from the request and the expense was created with $0 and no receipt. Switch to decodeURIComponent so reserved characters decode back to the on-disk name and the lookup succeeds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@abdulrahuman5196 Please 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] |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5aabc41f1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
Hi, @adhorodyski Kindly add author's screen recordings when the changes are done and ready for review? |
decodeURIComponent decodes reserved chars like # that decodeURI misses, but moveReceiptToDurableStorage builds file:// paths from raw filenames, so a name literally containing %23 must not be decoded. The two cases are indistinguishable from the string alone, so try the decoded path first and fall back to the raw path. Safe because the check only gates existence and the upload uses a separate uri field, so trying both candidates never changes what gets sent. Cover both fallback branches and a malformed-% escape in the unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@abdulrahuman5196 for some reason I cannot run the app on an Android emulator which is the only other case for this feature, iOS tests fine. Please proceed with testing here cc @mountiny |
|
@abdulrahuman5196 can you review please? |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
Hi will check today. |
This comment has been minimized.
This comment has been minimized.
|
The code looks good since it checks the decoded path if not falls back to raw path. I will check on different platforms and update soon. |
|
@abdulrahuman5196 are you available to review this one today? |
|
Yes will close out in couple of hours |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-07-15.at.12.08.52.AM.movAndroid: mWeb ChromeScreen.Recording.2026-07-15.at.12.06.10.AM.moviOS: HybridAppScreen.Recording.2026-07-15.at.1.46.44.AM.moviOS: mWeb SafariScreen.Recording.2026-07-15.at.12.54.39.AM.movMacOS: Chrome / SafariScreen.Recording.2026-07-15.at.12.31.21.AM.mov |
abdulrahuman5196
left a comment
There was a problem hiding this comment.
Changes looks good and works well. Reviewers checklist is also complete.
All yours. @mountiny
🎀 👀 🎀
C+ Reviewed
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.35-1 🚀
|
|
🤖 I reviewed the changes in this PR against the help site files under No help-site changes are required. This is a purely internal bug fix and does not change any documented, user-facing behavior. Why no docs update is needed
Because there is no user-facing documentation impact, I did not create a draft PR. If you'd rather I add a new troubleshooting note about sharing files with special characters, let me know and I'll draft one. @adhorodyski, since no help-site changes are required, no draft PR was created. If you believe a help article should be added or updated for this flow, reply and I'll draft one. |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.4.35-6 🚀
|
A file shared into the app arrives as a percent-encoded file:// URI (NSURL absoluteString on iOS, Uri.toString() on Android), but several consumers converted it to a filesystem path by only stripping the scheme, so any filename with a reserved character (#, and on some paths even a space) pointed at a file that does not exist on disk. Two changes close the class of bugs behind Expensify#95852 instead of patching one consumer at a time: 1. moveReceiptToDurableStorage now sanitizes the on-disk filename with the existing cleanFileName helper, so the file:// URIs it produces can never contain characters that make percent-decoding ambiguous. The user-visible filename is unaffected: it travels separately on the file object's name field everywhere (verified across receipt display, Onyx receipt.filename, and the FormData upload payload). 2. A new fileURIToPath helper (strip scheme, decodeURIComponent, fall back to the raw path on invalid escapes) replaces the hand-rolled conversions in getFileSize (the confirmed break on the share path), verifyFileFormat, cropOrRotateImage, and the Android local-file download branch, which previously used decodeURI and left reserved characters encoded. Only file:// URIs are decoded; content:// and https:// pass through untouched. checkFileExists and the fetch-based consumers (readFileAsync, the FormData uri) are deliberately unchanged: the former must keep its decoded-then-raw fallback for pre-existing queued receipts, the latter require the encoded form.
|
Hi, @mountiny Could you kindly trigger a separate payment issue for this PR? Seems the PR is linked to a parent issue, where i am not assigned. |
|
Done |
Explanation of Change
When you share a file into Expensify (for example, print an email as a PDF and share it), the app saves the file and remembers its path. Before uploading, it checks that the file is still there.
That check decoded the path the wrong way. iOS escapes special characters in the path: a space becomes
%20and a#becomes%23. The old code useddecodeURI, which turns%20back into a space but leaves%23alone. So for a file namedReceipt #42.pdf, the app looked for a file ending in%2342.pdf, which does not exist. It decided the file was missing and dropped the receipt. The expense was then created with $0, no receipt, and no error.The fix switches to
decodeURIComponent, which decodes every escaped character including#. But one producer,moveReceiptToDurableStorage, builds afile://path from the raw filename without encoding it, so a file whose name literally contains%23must not be decoded. The two cases are indistinguishable from the string alone, so the check now tries the decoded path first and falls back to the raw path. This is safe because the check only answers "does this file exist" and the actual upload uses a separateurifield, so trying both candidates never corrupts what gets uploaded.Scenarios now covered by
tests/unit/checkFileExistsTest.ts:file://prefix stripped before the lookup%20decoded to a space%23decoded to#, the reported bug%23, falls back to the raw path%escape like50%, decode throws and falls back to the raw pathSeveral other helpers (
getFileSize,verifyFileFormat,cropOrRotateImage,moveReceiptToDurableStorage) do their ownfile://→path conversion and none percent-decode, so they'd mishandle an encoded path too. Reachability varies and I haven't confirmed each; consolidating them behind one helper should be tracked as a follow-up and is out of scope here.Fixed Issues
$ #95673
PROPOSAL:
Tests
#in its file name. The easy way: open an email in Gmail, choose Print, then Share, then Expensify. Name or pick a file whose name contains a#, for exampleReceipt #42.pdf.#. Verify it still uploads with the receipt attached.Offline tests
#into Expensify and submit the expense.QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Logic-only fix, covered by the unit test in
tests/unit/checkFileExistsTest.ts.Android: Native
Android: mWeb Chrome
iOS: Native
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari