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

[$250] Incorrect parsing for backticks with a space in between them #48101

Closed
6 tasks done
dangrous opened this issue Aug 27, 2024 · 37 comments
Closed
6 tasks done

[$250] Incorrect parsing for backticks with a space in between them #48101

dangrous opened this issue Aug 27, 2024 · 37 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@dangrous
Copy link
Contributor

dangrous commented Aug 27, 2024

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:
Reproducible in staging?: yes
Reproducible in production?: yes
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by:
Slack conversation: not Slack but #46917 (comment)

Action Performed:

  1. Send the following input:
it uses`;`separated fields because the line number column could have`:`in them ` ` with space

Expected Result:

The input should look like

it uses;separated fields because the line number column could have:in them with space

(The space at the end is in a code block)

Actual Result:

The input looks like

image

(The space at the end is not in a code block, the backticks are visible)

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Yes

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

See above.

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e928bacaaf9c0339
  • Upwork Job ID: 1831034909462647027
  • Last Price Increase: 2024-09-03
  • Automatic offers:
    • hoangzinh | Reviewer | 103821976
    • tsa321 | Contributor | 103821978
Issue OwnerCurrent Issue Owner: @hoangzinh
@dangrous dangrous added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 27, 2024
Copy link

melvin-bot bot commented Aug 27, 2024

Triggered auto assignment to @muttmuure (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.

@dangrous
Copy link
Contributor Author

The parsing is actually wonkier than this on staging/prod so this bug isn't visible yet, but it will be when THAT parsing is fixed by #47838. Making this so I don't forget, but no action at the moment @muttmuure!

Copy link

melvin-bot bot commented Aug 27, 2024

📣 @c0ffincolors! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Nodebrute
Copy link
Contributor

Nodebrute commented Aug 27, 2024

Edited by proposal-police: This proposal was edited at 2024-08-27 16:19:13 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Incorrect parsing for backticks with a space in between them

What is the root cause of that problem?

We are checking that there is at least one whitespace character
https://github.com/Expensify/expensify-common/blob/d11466167bc562447d2dfdad624145040153efae/lib/ExpensiMark.ts#L193

What changes do you think we should make in order to solve the problem?

Remove \S+? from this regex
https://github.com/Expensify/expensify-common/blob/d11466167bc562447d2dfdad624145040153efae/lib/ExpensiMark.ts#L193

Updated regex

                regex: /(\B|_|)&#x60;((?:&#x60;)*)(?!&#x60;)(.*?.*?)(?<!&#x60;)((?:&#x60;)*)(&#x60;)(\B|_|)(?!&#x60;|[^<]*<\/pre>|[^<]*<\/video>)/gm,

Result:
Screenshot 2024-08-27 at 9 18 22 PM

Or

                regex: /(\B|_|)&#x60;((?:&#x60;)*)(?!&#x60;)(?<!&#x60;)((?:&#x60;)*)(&#x60;)(\B|_|)(?!&#x60;|[^<]*<\/pre>|[^<]*<\/video>)/gm,

What alternative solutions did you explore? (Optional)

@tsa321
Copy link
Contributor

tsa321 commented Aug 28, 2024

Edited by proposal-police: This proposal was edited at 2024-08-28 11:10:18 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Incorrect parsing for backticks with a space in between them

What is the root cause of that problem?

The regex for inline code:

https://github.com/Expensify/expensify-common/blob/d11466167bc562447d2dfdad624145040153efae/lib/ExpensiMark.ts#L193

that will be modified into :

/(\B|_|)&#x60;((?:&#x60;)*)(?!&#x60;)(.*?\S+?.*?)(?<!&#x60;)((?:&#x60;)*)(&#x60;)(\B|_|)(?!&#x60;|[^<]*<\/pre>|[^<]*<\/video>)/gm

won't allow space only inside backtick, in the (.*?\S+?.*?) part

What changes do you think we should make in order to solve the problem?

Modify the regex into:

/(\B|_|)&#x60;((?:&#x60;)*)(?!&#x60;)(.+?)(?<!&#x60;)((?:&#x60;)*)(&#x60;)(\B|_|)(?!&#x60;|[^<]*<\/pre>|[^<]*<\/video>)/gm

We also need to escape the space character as &nbsp; due to the issue #8720, which is addressed by Expensify/expensify-common#443. Sending an unescaped space or a space-only inlinecode or code block, results in a server error response.


We should add ' ' : '&nbsp;' in:

lib/utils.ts#L13

Additionally, in:

lib/utils.ts#L33

we add '&nbsp;': ' '

And in:

lib/utils.ts#L43

we add |nbsp|

but this will breaks many regexes. We could adjust the regexes accordingly.


Alternatively, we could escape the space in before return of replace function of ExpensiMark:

https://github.com/Expensify/expensify-common/blob/331f53580a4ddd7f1c8e73c7c1494d0bb22962c7/lib/ExpensiMark.ts#L855

Or right before sending the comment:

reportCommentText = reportComment.commentText;

and in here:

reportCommentText = ReportUtils.getParsedComment(text ?? '', {reportID});

or directly in here:

reportComment: reportCommentText,

Or another more appropriate place.

@melvin-bot melvin-bot bot added the Overdue label Aug 29, 2024
@dangrous
Copy link
Contributor Author

almost ready to open this up officially, PR is merged but not yet deployed

Copy link

melvin-bot bot commented Aug 30, 2024

@muttmuure Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@muttmuure
Copy link
Contributor

Will wait until we need an external contributor

@melvin-bot melvin-bot bot removed the Overdue label Sep 1, 2024
@muttmuure
Copy link
Contributor

Not overdue

@dangrous
Copy link
Contributor Author

dangrous commented Sep 3, 2024

Okay we're ready to go on this one, will make it external

@dangrous dangrous added the External Added to denote the issue can be worked on by a contributor label Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01e928bacaaf9c0339

@melvin-bot melvin-bot bot changed the title Incorrect parsing for backticks with a space in between them [$250] Incorrect parsing for backticks with a space in between them Sep 3, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

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

@hoangzinh
Copy link
Contributor

@tsa321 @Nodebrute Thanks for proposals, everyone. I think both of you pointed out the correct root cause. But both solutions would cause another issue where a user sends backticks with a space.

Steps to reproduce

  1. Go to any chats
  2. Send a message
  3. Expected that it's sent successfully

Screenshot 2024-09-04 at 18 52 30

@tsa321
Copy link
Contributor

tsa321 commented Sep 4, 2024

@hoangzinh yes, that is way we must convert the space with &nbsp; like what I mentioned in my proposal

@hoangzinh
Copy link
Contributor

@tsa321 I tried to apply your solution, but still got same error. Can you share your recording and the AddComment API request body in this case? Thank you

@tsa321
Copy link
Contributor

tsa321 commented Sep 4, 2024

@hoangzinh here is the video:

api_req.mp4

@hoangzinh
Copy link
Contributor

@tsa321 Thanks for the updates. Your proposal looks good to me

Link to proposal #48101 (comment)

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 4, 2024

Triggered auto assignment to @deetergp, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 4, 2024
@melvin-bot melvin-bot bot removed the Overdue label Sep 11, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 12, 2024
@tsa321
Copy link
Contributor

tsa321 commented Sep 12, 2024

@hoangzinh PR is ready

Copy link

melvin-bot bot commented Oct 7, 2024

This issue has not been updated in over 15 days. @deetergp, @hoangzinh, @muttmuure, @tsa321 eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@deetergp
Copy link
Contributor

deetergp commented Oct 7, 2024

@muttmuure I think our automations failed to update, but the PR for this issue has been deployed to production.

@deetergp deetergp added Weekly KSv2 and removed Monthly KSv2 labels Oct 7, 2024
@dangrous
Copy link
Contributor Author

dangrous commented Oct 8, 2024

I think @muttmuure is still on leave, I'll reapply the label

@dangrous dangrous added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Oct 8, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

Triggered auto assignment to @anmurali (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.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 8, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

@deetergp, @hoangzinh, @anmurali, @tsa321 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@hoangzinh
Copy link
Contributor

BugZero Checklist:

@hoangzinh
Copy link
Contributor

not overdue, it's ready for payment cc @anmurali

Copy link

melvin-bot bot commented Oct 23, 2024

@deetergp, @hoangzinh, @anmurali, @tsa321 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@hoangzinh
Copy link
Contributor

cc @anmurali on payment

Copy link

melvin-bot bot commented Oct 31, 2024

@deetergp, @hoangzinh, @anmurali, @tsa321 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@hoangzinh
Copy link
Contributor

@anmurali
Copy link

anmurali commented Nov 5, 2024

Paid.

@anmurali anmurali closed this as completed Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants
@deetergp @dangrous @hoangzinh @anmurali @muttmuure @Nodebrute @tsa321 and others