Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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 #11693

Closed
kavimuru opened this issue Oct 9, 2022 · 22 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Oct 9, 2022

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:

Recording.658.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 kavimuru added AutoAssignerTriage Auto assign issues for triage to an available triage team member Daily KSv2 labels Oct 9, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 9, 2022

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

@melvin-bot melvin-bot bot removed the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Oct 9, 2022
@Beamanator Beamanator assigned Beamanator and unassigned mateocole Oct 10, 2022
@Beamanator Beamanator added External Added to denote the issue can be worked on by a contributor Engineering labels Oct 10, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 10, 2022

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 10, 2022

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 10, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 10, 2022

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

@melvin-bot melvin-bot bot changed the title BUG: Copy pasting a string with html special characters from the chat to another source results in getting decoded characters [$250] BUG: Copy pasting a string with html special characters from the chat to another source results in getting decoded characters Oct 10, 2022
@Beamanator
Copy link
Contributor

Moving this along a bit - this is something we usually work out externally 👍

@Ollyws
Copy link
Contributor

Ollyws commented Oct 10, 2022

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.

const getCurrentSelection = () => {
const domRepresentation = parseDocument(getHTMLOfSelection());
domRepresentation.children = _.map(domRepresentation.children, replaceNodes);
const newHtml = render(domRepresentation);
return newHtml || '';
};

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:

issue11693.mp4

@tjferriss tjferriss added Weekly KSv2 and removed Daily KSv2 labels Oct 11, 2022
@tjferriss
Copy link
Contributor

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

@michaelhaxhiu
Copy link
Contributor

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 Implement infinite sessions #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!

@mollfpr
Copy link
Contributor

mollfpr commented Oct 12, 2022

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 || '';
 };
Screen.Recording.2022-10-12.at.21.30.21.mov

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 12, 2022
@mananjadhav
Copy link
Collaborator

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

cc - @Beamanator

🎀 👀 🎀 
C+ reviewed

@melvin-bot melvin-bot bot added the Overdue label Oct 17, 2022
@melvin-bot melvin-bot bot removed Help Wanted Apply this label when an issue is open to proposals by contributors Daily KSv2 labels Oct 17, 2022
@melvin-bot melvin-bot bot added the Weekly KSv2 label Oct 17, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 17, 2022

📣 @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 melvin-bot bot removed the Overdue label Oct 17, 2022
@mollfpr
Copy link
Contributor

mollfpr commented Oct 17, 2022

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

@Beamanator
Copy link
Contributor

I think you're right @mollfpr - sounds like a different part of the codebase 👍

@tjferriss
Copy link
Contributor

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

@mollfpr
Copy link
Contributor

mollfpr commented Oct 18, 2022

@tjferriss Applied, thank you!

@mananjadhav
Copy link
Collaborator

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

@puneetlath puneetlath added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 19, 2022
@tjferriss
Copy link
Contributor

tjferriss commented Oct 20, 2022

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

@mananjadhav
Copy link
Collaborator

Thanks @tjferriss I've accepted for C+

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 24, 2022
@melvin-bot melvin-bot bot changed the title [$250] BUG: Copy pasting a string with html special characters from the chat to another source results in getting decoded characters [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 Oct 24, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 24, 2022

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.2.18-10 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 2022-10-31. 🎊

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Oct 31, 2022
@mananjadhav
Copy link
Collaborator

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

@tjferriss
Copy link
Contributor

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

@parasharrajat
Copy link
Member

It seems that this issue's PR caused a regression #12271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants