App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2022-10-31] [$250] BUG: Copy pasting a string with html special characters from the chat to another source results in getting decoded characters

Open kavimuru opened this issue 2 years ago β€’ 19 comments

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:

  1. Open NewDot
  2. Send some markdown text to any chat (html special characters)(SELECT count(1) FROM receipts WHERE state IN (3,4,5) AND created >= date("now", "-30 day");)
  3. Copy the sent text using (Ctrl+C) and paste it in Notepad, slack etc)

Expected Result:

The text shouldn't be pasted as decoded characters

Actual Result:

Text is pasted as decoded characters (SELECT count(1) FROM receipts WHERE state IN (3,4,5) AND created >= date("now", "-30 day");)

Workaround:

Unknown

Platform:

Where is this issue occurring?

  • Web

Version Number: 1.2.12-2 Reproducible in staging?: y Reproducible in production?: y Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:

https://user-images.githubusercontent.com/43996225/194781995-bbcd4efe-9c2e-42c3-adfa-aeb42feac86e.mp4

Screen Shot 2022-10-07 at 11 16 55 AM

Expensify/Expensify Issue URL: Issue reported by: @coleaeason Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1664835972610759

View all open jobs on GitHub

kavimuru avatar Oct 09 '22 22:10 kavimuru

Triggered auto assignment to @mateocole (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

melvin-bot[bot] avatar Oct 09 '22 22:10 melvin-bot[bot]

Triggered auto assignment to @tjferriss (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

melvin-bot[bot] avatar Oct 10 '22 07:10 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

melvin-bot[bot] avatar Oct 10 '22 07:10 melvin-bot[bot]

Current assignee @Beamanator is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] avatar Oct 10 '22 07:10 melvin-bot[bot]

Moving this along a bit - this is something we usually work out externally πŸ‘

Beamanator avatar Oct 10 '22 07:10 Beamanator

Proposal

This is caused by the render method from the dom-serializer module in SelectionScraper, which renders DOM nodes to a string. The string it returns always contains certain characters as escaped and there doesn't seem to be any way to get it to return an unescaped string.

https://github.com/Expensify/App/blob/f654cc13794aa749a29b6561bad94d80a9580fd4/src/libs/SelectionScraper/index.js#L132-L138

One way to resolve this is to use the underscore unescape function to unescape the returned string.

- const newHtml = render(domRepresentation);
+ const newHtml = _.unescape(render(domRepresentation));

result:

https://user-images.githubusercontent.com/11609254/194873114-f22fc84f-5827-4d45-a603-e4ac70688301.mp4

Ollyws avatar Oct 10 '22 13:10 Ollyws

Posting is on UpWorks....

Internal job posting - https://www.upwork.com/ab/applicants/1579848042371682304/job-details

External job posting - https://www.upwork.com/jobs/~0125c406f21abe54eb

tjferriss avatar Oct 11 '22 14:10 tjferriss

Couple of notes:

  • No need to include the internal job posting next time! We just need to share the external job πŸ‘
  • I just discovered the "How do I create an Upwork job?" stack overflow post needed a small tweak, and made that tweak in step #7:
  1. Make sure to remove the https:// portion from the GH URL (if it's left there, then the job may be flagged and removed by Upwork).
  • This looks good otherwise!

michaelhaxhiu avatar Oct 11 '22 17:10 michaelhaxhiu

Proposal

Using Str.htmlDecode to decode HTML encoded string.

diff --git a/src/libs/SelectionScraper/index.js b/src/libs/SelectionScraper/index.js
index 99405259e..317b72741 100644
--- a/src/libs/SelectionScraper/index.js
+++ b/src/libs/SelectionScraper/index.js
@@ -133,7 +133,7 @@ const getCurrentSelection = () => {
     const domRepresentation = parseDocument(getHTMLOfSelection());
     domRepresentation.children = _.map(domRepresentation.children, replaceNodes);

-    const newHtml = render(domRepresentation);
+    const newHtml = Str.htmlDecode(render(domRepresentation));
     return newHtml || '';
 };

https://user-images.githubusercontent.com/25520267/195370739-1b8ba3ba-47ba-4032-af95-b81439966b16.mov

mollfpr avatar Oct 12 '22 14:10 mollfpr

@mollfpr's proposal to use Str.htmlDecode looks better.

cc - @Beamanator

πŸŽ€Β πŸ‘€Β πŸŽ€Β  C+ reviewed

mananjadhav avatar Oct 14 '22 22:10 mananjadhav

πŸ“£ @mollfpr You have been assigned to this job by @Beamanator! Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

melvin-bot[bot] avatar Oct 17 '22 09:10 melvin-bot[bot]

I found a bug when you try to copy the last chat from a thread by highlighting all the text, it's copying the text I select and also some random text. https://expensify.slack.com/archives/C01GTK53T8Q/p1666000158578689

I think that bug has nothing to do with this issue right? @mananjadhav @Beamanator

mollfpr avatar Oct 17 '22 09:10 mollfpr

I think you're right @mollfpr - sounds like a different part of the codebase πŸ‘

Beamanator avatar Oct 18 '22 11:10 Beamanator

@mollfpr can you please apply for the job on Upworks? https://www.upwork.com/jobs/~0125c406f21abe54eb

tjferriss avatar Oct 18 '22 22:10 tjferriss

@tjferriss Applied, thank you!

mollfpr avatar Oct 18 '22 22:10 mollfpr

@tjferriss fyi, I've applied to the same link for C+.

mananjadhav avatar Oct 19 '22 02:10 mananjadhav

Hired @mananjadhav as C+ and @mollfpr to fix the issue. Can you both confirm here once accepted?

tjferriss avatar Oct 20 '22 22:10 tjferriss

Thanks @tjferriss I've accepted for C+

mananjadhav avatar Oct 20 '22 22:10 mananjadhav

The solution for this issue has been :rocket: deployed to production :rocket: in version 1.2.18-10 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

  • https://github.com/Expensify/App/pull/11905
  • https://github.com/Expensify/App/pull/11905

If no regressions arise, payment will be issued on 2022-10-31. :confetti_ball:

melvin-bot[bot] avatar Oct 24 '22 23:10 melvin-bot[bot]

@tjferriss Quick bump on the Upwork payment for this one.

mananjadhav avatar Nov 02 '22 05:11 mananjadhav

Yes, thank you. I've initiated the payments in Upworks. The contract has been completed and the Upwork post has been closed.

tjferriss avatar Nov 03 '22 04:11 tjferriss

It seems that this issue's PR caused a regression https://github.com/Expensify/App/issues/12271

parasharrajat avatar Nov 16 '22 00:11 parasharrajat