Repository navigation
Conversation
8f5e847 to
945778b
Compare
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
945778b to
78dbfdb
Compare
|
@ZhenjaHorbach 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 |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
Pull request overview
This PR addresses receipt/file handling failures caused by percent-encoded file:// URIs (e.g., spaces as %20, # as %23) being passed into filesystem APIs without decoding. It centralizes decoding/normalization behind a single helper and ensures newly persisted receipt filenames are unambiguous on disk.
Changes:
- Introduces a shared
fileURIToPathhelper to convertfile://URIs into decoded POSIX paths (with safe fallback on malformed percent-encoding). - Replaces ad-hoc
file://stripping / partial decoding across multiple filesystem call sites withfileURIToPath. - Sanitizes the on-disk filename produced by
moveReceiptToDurableStorageviacleanFileNameto avoid ambiguous%/#cases and improve durability.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/verifyFileFormatTest.ts | Adds coverage to ensure verifyFileFormat reads from decoded POSIX paths for encoded file:// URIs. |
| tests/unit/libs/receiptDurableStorageTest.ts | Expands tests for decoding source URIs and sanitizing destination filenames in durable receipt storage. |
| tests/unit/getFileSizeTest.ts | Adds tests verifying getFileSize stats decoded paths for encoded share URIs. |
| tests/unit/fileURIToPathTest.ts | Adds unit tests for fileURIToPath decoding behavior and non-file:// pass-through. |
| src/pages/Share/getFileSize/index.native.ts | Uses fileURIToPath before calling RNFS.stat to handle encoded share URIs. |
| src/libs/moveReceiptToDurableStorage/index.native.ts | Decodes source file:// URIs before moving; sanitizes on-disk destination filename via cleanFileName. |
| src/libs/fileURIToPath.ts | New helper to convert file:// URIs into decoded filesystem paths with fallback on invalid encoding. |
| src/libs/fileDownload/index.android.ts | Uses fileURIToPath for local file:// downloads so Android media copy/unlink receives a bare POSIX path. |
| src/libs/fileDownload/FileUtils.ts | Updates verifyFileFormat to use fileURIToPath instead of only stripping file://. |
| src/libs/fileDownload/checkFileExists/index.ts | Uses fileURIToPath for the decoded candidate path while keeping the decoded-then-raw fallback behavior. |
| src/libs/cropOrRotateImage/index.native.ts | Uses fileURIToPath for RNFetchBlob.fs.stat calls on manipulated image URIs and fallback path usage. |
| src/components/ImportOnyxState/index.native.tsx | Uses fileURIToPath to convert file:// URIs to filesystem paths before blob-util operations. |
| src/components/FilePicker/index.native.tsx | Uses fileURIToPath before RNFetchBlob.fs.stat to support encoded file:// URIs. |
| src/components/AttachmentPicker/index.native.tsx | Uses fileURIToPath before RNFetchBlob.fs.stat when size is missing, supporting encoded file:// URIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp2026-07-17.17.10.56.movAndroid: mWeb Chrome2026-07-17.17.10.56.moviOS: HybridApp2026-07-17.16.59.13.moviOS: mWeb Safari2026-07-17.17.02.51.movMacOS: Chrome / Safari2026-07-17.16.56.55.mov2026-07-17.17.12.50.mov |
|
Changes look and work good! |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ 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/mountiny in version: 9.4.41-0 🚀
|
|
🤖 I reviewed the changes in this PR against the help site articles under No help site changes are required. This is an internal logic-only bug fix: it adds a There is no user-facing surface change here — no new or renamed feature, tab, setting, button, or workflow — and the fix is transparent to users. The help site never documented any restriction on special characters in receipt filenames (I searched the articles for filename-related guidance and the only matches concern unrelated import/export/API topics), so there is nothing to add, correct, or remove. Since no documentation update is needed, I did not create a draft PR. @adhorodyski, if you believe a specific article should mention this behavior, let me know which one and I'll draft the update. |
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.41-4 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Follow-up to #95852, which fixed one consumer (
checkFileExists).A file shared into the app arrives as a percent-encoded
file://URI: a space becomes%20and a#becomes%23. Several consumers turned that URI into a filesystem path by only stripping thefile://prefix, without decoding. Walk through a file namedReceipt #42.pdf: it arrives as.../Receipt%20%2342.pdf, the consumer strips the prefix and hands the still-encoded string to the filesystem, and the lookup fails because no file with that literal name exists on disk.Two changes close this class of bugs:
fileURIToPathhelper turns afile://URI into the decoded path, and falls back to the raw path when the string is not valid percent-encoding. It replaces the one-off conversions ingetFileSize(the confirmed break:ShareRootPagefeeds it the encoded share URI),verifyFileFormat,cropOrRotateImage,AttachmentPicker,FilePicker,ImportOnyxState, the decode step ofcheckFileExists, and the Android local-file download branch, which useddecodeURIand left%23encoded. Onlyfile://URIs are decoded.content://URIs and remote URLs pass through untouched, so Android picker files and downloads behave exactly as before.moveReceiptToDurableStoragenow sanitizes the on-disk filename with the existingcleanFileNamehelper, so thefile://URIs it produces never contain#,%, or a space. Without this, a file literally namedReceipt %2342.pdfand an encodedReceipt #42.pdfare the same string, and no decode can tell them apart. The filename users see is not affected: it travels separately on the file object'snamefield (verified across receipt display, Onyxreceipt.filename, and the upload payload).Deliberately unchanged:
checkFileExistskeeps its stat-decoded-then-stat-raw fallback, because receipts queued offline before this change can still point at files with unsanitized names. The upload consumers (readFileAsyncand the FormDatauri) also stay on the encoded URI, which is the formfetchneeds.Fixed Issues
$ #95673
PROPOSAL:
Tests
#and a space into Expensify (open an email in Gmail → Print → Share → Expensify, e.g.Receipt #42.pdf) and submit the expense. Verify the expense is created with the receipt attached, not $0.#in the filename via the in-app attachment picker and submit. Verify the receipt uploads and displays.npx jest tests/unit/fileURIToPathTest.ts tests/unit/getFileSizeTest.ts tests/unit/libs/receiptDurableStorageTest.ts tests/unit/verifyFileFormatTest.ts tests/unit/checkFileExistsTest.ts(34 tests).Offline tests
#into Expensify and submit the expense. Turn the network back on. Verify the receipt uploads once the queue drains and the expense shows the receipt instead of $0.QA Steps
Same as Tests steps 1-2 above.
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 unit tests.
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari