You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2025-07-28] [$250] Android - Chat - App crash when paste text or image that was copied from WPS Office #63191
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Version Number: 9.1.54-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail:#61322 Issue reported by: Applause - Internal Team
Action Performed:
Create text and image as Word Document
Copy the text or image via WPS Office app
Open the Expensify app
Go to any chat and paste into composer
Expected Result:
App should not crash and modal showing just the image
Actual Result:
App crash when paste text or image that was copied from WPS Office
Note:
Not reproducible when copy from Docs app
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
Android: App
Android: mWeb Chrome
iOS: App
iOS: mWeb Safari
iOS: mWeb Chrome
Windows: Chrome
MacOS: Chrome / Safari
MacOS: Desktop
Platforms Tested:
On which of our officially supported platforms was this issue tested:
Android: App
Android: mWeb Chrome
iOS: App
iOS: mWeb Safari
iOS: mWeb Chrome
Windows: Chrome
MacOS: Chrome / Safari
MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidenceBug6846807_1748626231831.Paste_via_WPT_Crash.mp4
🚨 Edited by proposal-police: This proposal was edited at 2025-05-30 22:00:49 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
App crash when paste text or image that was copied from WPS Office
Cannot paste text from Google Docs too
What is the root cause of that problem?
Cannot paste text from Google Docs too
In this PR #60501, we delegated the handling of clipboard data that is an image to our own composer, instead of calling the default handler of react-native. Because that default handler will paste the image (rich text) as plain text.
That is not correct, because a non-null URI can also represent any kinds of data. For example, in this case, the URI of the copied text (or any other copied data) from Google Docs is content://com.google.android.apps.docs.editors.kix.editors.clipboard?uuid=....
Next, in pasteFile callback in Composer, we ignore if type is text/plain (which is correct in this case), because we assumed that the plain text should have been handled by react-native default handler as mentioned above.
So, we stopped react-native default handler because we misinterpreted the clip data as an image, and did not handle the pasted plain text in our own callback, causing this text cannot be pasted.
App crash when paste text or image that was copied from WPS Office
The clipped data type is evaluated using ContentResolver with WPS URI was content://cn.wps.moffice_eng.provider/copy:
I don't know why, maybe WPS office has not implemented the ContentProvided with Google so that their URI can be recognized by ContentResolver above, so their URI here cannot be recognized and thus type is null.
And same with the Google Docs case, this is a plain text but misunderstood as an image, so the nulltype is passed straight to the onPaste callback.
Later inside pasteFile in Composer, mimeType here is empty string, same with originalFileExtension, because this is not a file URI, causing mimeDb[mimeType] to be undefined and leading to crash:
+ // Prevents default behavior to avoid inserting raw binary data into the text field
+ return true;
+ }
if (itemUri != null) {
ContentResolvercr = getReactContext(this).getContentResolver();
type = cr.getType(itemUri);
if (type != null && !type.equals(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
data = itemUri.toString();
// The rest
POC
Google Docs
Screen.Recording.2025-06-11.at.10.47.00.mov
Pasting image is intact:
Screen.Recording.2025-06-11.at.10.57.09.mov
WPS Office
Screen.Recording.2025-06-11.at.10.52.52.mov
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
NA
What alternative solutions did you explore? (Optional)
Early return if clipboardContent?.type is nullhere.
@mkzie2 Can you please describe your reproduction steps for the Google Docs case in more detail? I tested Google Docs on Android native with formatted text and did not see this issue (there is a screen recording on #61322). Also @lanitochka17’s report says that Google Docs was OK. Perhaps there is something specific about your test case?
@yellowtailfan No special reproduction steps, just copy any text from Google Docs and paste into composer. It said "New Expensify Dev pasted your clipboard" but does not paste anything. I think this is not a regression from your PR.
Thanks @mkzie2. I'm still interested as although my changes are not exercised on Android this is in a related area.
I tried to reproduce this with the 9.1.54-6-staging binary using Google Docs on a simulator running API 36 but it works fine for me. I tried some text with bold and plain formatting, and also a couple of paragraphs of plain text. Recipe I tried:
I tried to reproduce this with the 9.1.54-6-staging binary using Google Docs on a simulator running API 36 but it works fine for me. I tried some text with bold and plain formatting, and also a couple of paragraphs of plain text.
Hmm I think this MIGHT be device/application version specific. Let me check this on more devices and get back to you.
changed the title [-][$250] Android - Chat - App crash when paste text or image that was copied from WPS Office[/-][+][Due for payment 2025-07-28] [$250] Android - Chat - App crash when paste text or image that was copied from WPS Office[/+]on Jul 21, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.83-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@cead22@johncschuster@jayeshmangwani / @mkzie2 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
1a. Result of the original design (eg. a case wasn't considered)
1b. Mistake during implementation
1c. Backend bug
1z. Other:
Where bug was reported:
2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
2b. Reported on staging (eg. found during regression or PR testing)
2d. Reported on a PR
2z. Other:
Who reported the bug:
3a. Expensify user
3b. Expensify employee
3c. Contributor
3d. QA
3z. Other:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Copy plain text or an image from the WPS Office app.
Long-press in the composer and select Paste.
Verify that the app does not crash and the content is pasted correctly.
Copy plain text from the Google Docs app.
Long-press in the composer and select Paste.
Verify that the text is pasted as expected.
Copy an image or chart from the Google Docs app.
Long-press in the composer and select Paste.
Verify that the image or chart is pasted correctly.
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon May 30, 2025
Triggered auto assignment to @johncschuster (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.mkzie2 commentedon May 30, 2025
🚨 Edited by proposal-police: This proposal was edited at 2025-05-30 22:00:49 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
In this PR #60501, we delegated the handling of clipboard data that is an image to our own composer, instead of calling the default handler of react-native. Because that default handler will paste the image (rich text) as plain text.
App/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch
Lines 510 to 511 in 7083c03
To detect an image being copied, we checked if the clip item URI is not null:
App/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch
Line 503 in 7083c03
That is not correct, because a non-null URI can also represent any kinds of data. For example, in this case, the URI of the copied text (or any other copied data) from Google Docs is
content://com.google.android.apps.docs.editors.kix.editors.clipboard?uuid=....Next, in
pasteFilecallback inComposer, we ignore iftypeistext/plain(which is correct in this case), because we assumed that the plain text should have been handled by react-native default handler as mentioned above.App/src/components/Composer/implementation/index.native.tsx
Lines 113 to 114 in 9922bbd
So, we stopped react-native default handler because we misinterpreted the clip data as an image, and did not handle the pasted plain text in our own callback, causing this text cannot be pasted.
The clipped data
typeis evaluated usingContentResolverwith WPS URI wascontent://cn.wps.moffice_eng.provider/copy:App/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch
Line 505 in 7083c03
I don't know why, maybe WPS office has not implemented the
ContentProvidedwith Google so that their URI can be recognized byContentResolverabove, so their URI here cannot be recognized and thustypeisnull.And same with the Google Docs case, this is a plain text but misunderstood as an image, so the
nulltypeis passed straight to theonPastecallback.Later inside
pasteFileinComposer,mimeTypehere is empty string, same withoriginalFileExtension, because this is not a file URI, causingmimeDb[mimeType]to be undefined and leading to crash:App/src/components/Composer/implementation/index.native.tsx
Lines 116 to 120 in 9922bbd
What changes do you think we should make in order to solve the problem?
We should skip the logic for image if the type resolved from the URI is not plain text:
App/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch
Lines 503 to 512 in 7083c03
POC
Google Docs
Screen.Recording.2025-06-11.at.10.47.00.mov
Pasting image is intact:
Screen.Recording.2025-06-11.at.10.57.09.mov
WPS Office
Screen.Recording.2025-06-11.at.10.52.52.mov
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
NA
What alternative solutions did you explore? (Optional)
Early return if
clipboardContent?.typeisnullhere.Add optional chaining to
mimeDb[mimeType]hereApp/src/components/Composer/implementation/index.native.tsx
Line 120 in 9922bbd
mkzie2 commentedon May 30, 2025
@johncschuster This bug is blocking copy pasting from Google Docs as well so we'd better fix it quick.
yellowtailfan commentedon May 30, 2025
@mkzie2 Can you please describe your reproduction steps for the Google Docs case in more detail? I tested Google Docs on Android native with formatted text and did not see this issue (there is a screen recording on #61322). Also @lanitochka17’s report says that Google Docs was OK. Perhaps there is something specific about your test case?
mkzie2 commentedon May 30, 2025
@yellowtailfan No special reproduction steps, just copy any text from Google Docs and paste into composer. It said "New Expensify Dev pasted your clipboard" but does not paste anything. I think this is not a regression from your PR.
yellowtailfan commentedon May 31, 2025
Thanks @mkzie2. I'm still interested as although my changes are not exercised on Android this is in a related area.
I tried to reproduce this with the 9.1.54-6-staging binary using Google Docs on a simulator running API 36 but it works fine for me. I tried some text with bold and plain formatting, and also a couple of paragraphs of plain text. Recipe I tried:
melvin-bot commentedon Jun 3, 2025
@johncschuster Whoops! This issue is 2 days overdue. Let's get this updated quick!
johncschuster commentedon Jun 3, 2025
Looks like this is being covered in #57241
mkzie2 commentedon Jun 3, 2025
@johncschuster #57241 is another issue and I can still reproduce this one on production. @yellowtailfan Can you confirm?
mkzie2 commentedon Jun 3, 2025
Hmm I think this MIGHT be device/application version specific. Let me check this on more devices and get back to you.
39 remaining items
[-][$250] Android - Chat - App crash when paste text or image that was copied from WPS Office[/-][+][Due for payment 2025-07-28] [$250] Android - Chat - App crash when paste text or image that was copied from WPS Office[/+]melvin-bot commentedon Jul 21, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 21, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.83-5 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 2025-07-28. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jul 21, 2025
@cead22 @johncschuster @jayeshmangwani / @mkzie2 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
johncschuster commentedon Jul 22, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
jayeshmangwani commentedon Jul 28, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: fix: binary content appears in composer when pasting image #60501 (comment)
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Do we agree 👍 or 👎
johncschuster commentedon Jul 28, 2025
Payment Summary
Contributor: @mkzie2 paid $250 via Upwork ✅
Contributor+: @jayeshmangwani due $250 via NewDot
@jayeshmangwani, please request payment via NewDot!
johncschuster commentedon Jul 29, 2025
Payment has been issued via Upwork. All that's left is the payment via ND and we don't need to keep this open for that. Thanks all!