Skip to content

[Due for payment 2025-07-28] [$250] Android - Chat - App crash when paste text or image that was copied from WPS Office #63191

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


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:

  1. Create text and image as Word Document
  2. Copy the text or image via WPS Office app
  3. Open the Expensify app
  4. 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 evidence
Bug6846807_1748626231831.Paste_via_WPT_Crash.mp4

log.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021932087279620596935
  • Upwork Job ID: 1932087279620596935
  • Last Price Increase: 2025-06-09
  • Automatic offers:
    • mkzie2 | Contributor | 107702798
Issue OwnerCurrent Issue Owner: @johncschuster

Activity

  1. added
    Daily
    Bug
    on May 30, 2025
  2. melvin-bot commented on May 30, 2025

    @melvin-bot

    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.

  3. mkzie2 commented on May 30, 2025

    @mkzie2
    Contributor

    🚨 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.

    + // Prevents default behavior to avoid inserting raw binary data into the text field
    + return true;

    To detect an image being copied, we checked if the clip item URI is not null:

    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.

    if (clipboardContent?.type === 'text/plain') {
    return;

    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 null type 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:

    const mimeType = clipboardContent?.type ?? '';
    const fileURI = clipboardContent?.data;
    const baseFileName = fileURI?.split('/').pop() ?? 'file';
    const {fileName: stem, fileExtension: originalFileExtension} = splitExtensionFromFileName(baseFileName);
    const fileExtension = originalFileExtension || (mimeDb[mimeType].extensions?.[0] ?? 'bin');

    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:

    + if (itemUri != null) {
    + ContentResolver cr = getReactContext(this).getContentResolver();
    + type = cr.getType(itemUri);
    + data = itemUri.toString();
    + if (mPasteWatcher != null) {
    + mPasteWatcher.onPaste(type, data);
    + }
    + // Prevents default behavior to avoid inserting raw binary data into the text field
    + return true;
    + }

    if (itemUri != null) {
        ContentResolver cr = 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 null here.

    • Add optional chaining to mimeDb[mimeType] here

    const fileExtension = originalFileExtension || (mimeDb[mimeType].extensions?.[0] ?? 'bin');

  4. mkzie2 commented on May 30, 2025

    @mkzie2
    Contributor

    @johncschuster This bug is blocking copy pasting from Google Docs as well so we'd better fix it quick.

  5. yellowtailfan commented on May 30, 2025

    @yellowtailfan
    Contributor

    @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?

  6. mkzie2 commented on May 30, 2025

    @mkzie2
    Contributor

    @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.

  7. yellowtailfan commented on May 31, 2025

    @yellowtailfan
    Contributor

    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:

    1. Type text into new document in Google Docs
    2. (Optional) Apply bold formatting
    3. Copy
    4. Switch to Expensify and paste into chat
    5. Plain text appears with no formatting
  8. melvin-bot commented on Jun 3, 2025

    @melvin-bot

    @johncschuster Whoops! This issue is 2 days overdue. Let's get this updated quick!

  9. johncschuster commented on Jun 3, 2025

    @johncschuster
    Contributor

    Looks like this is being covered in #57241

  10. mkzie2 commented on Jun 3, 2025

    @mkzie2
    Contributor

    @johncschuster #57241 is another issue and I can still reproduce this one on production. @yellowtailfan Can you confirm?

  11. mkzie2 commented on Jun 3, 2025

    @mkzie2
    Contributor

    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.

  12. 39 remaining items

  13. added
    Weekly
    Awaiting Payment
    on Jul 21, 2025
  14. 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
  15. removed
    Reviewing
    on Jul 21, 2025
  16. melvin-bot commented on Jul 21, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  17. melvin-bot commented on Jul 21, 2025

    @melvin-bot

    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:

  18. melvin-bot commented on Jul 21, 2025

    @melvin-bot

    @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]

  19. johncschuster commented on Jul 22, 2025

    @johncschuster
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 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.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    Do we agree 👍 or 👎

  20. added
    Daily
    and removed
    Weekly
    on Jul 27, 2025
  21. jayeshmangwani commented on Jul 28, 2025

    @jayeshmangwani
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 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: 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

    1. Copy plain text or an image from the WPS Office app.
    2. Long-press in the composer and select Paste.
    3. Verify that the app does not crash and the content is pasted correctly.
    4. Copy plain text from the Google Docs app.
    5. Long-press in the composer and select Paste.
    6. Verify that the text is pasted as expected.
    7. Copy an image or chart from the Google Docs app.
    8. Long-press in the composer and select Paste.
    9. Verify that the image or chart is pasted correctly.

    Do we agree 👍 or 👎

  22. johncschuster commented on Jul 28, 2025

    @johncschuster
    Contributor

    Payment Summary

    Contributor: @mkzie2 paid $250 via Upwork ✅
    Contributor+: @jayeshmangwani due $250 via NewDot

    @jayeshmangwani, please request payment via NewDot!

  23. johncschuster commented on Jul 29, 2025

    @johncschuster
    Contributor

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions