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

[$1000] Chat - Certain characters are considered as 6 characters within the message box #26051

Closed
1 of 6 tasks
lanitochka17 opened this issue Aug 28, 2023 · 9 comments
Closed
1 of 6 tasks
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 Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 28, 2023

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


Action Performed:

  1. Insert a text with a length exceeding 15,000 characters
  2. Type characters such as: " , ç , à , & , é
  3. The total increments by 6 for each occurrence

Expected Result:

The overall count should increase by 1

Actual Result:

The overall count increased by 6

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.57-5

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

Notes/Photos/Videos: Any additional supporting documentation

6-char-Expensify.mp4
Recording.6026.mp4

Expensify/Expensify Issue URL:

Issue reported by: @hichamcc

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692470777922139

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ef4e9f58ef6fe5dd
  • Upwork Job ID: 1696338819616731136
  • Last Price Increase: 2023-08-29
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 28, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

Triggered auto assignment to @MitchExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Aug 28, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@akinwale
Copy link
Contributor

akinwale commented Aug 28, 2023

Proposal

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

When calculating the total comment length, characters with diacritics are being counted as Unicode characters (6 chars in length).

What is the root cause of that problem?

In getCommentLength method implementation found in ReportUtils, the regex used to replace the comment is [^ -~] which replaces all characters greater than ASCII code 127 with a Unicode representation. This also converts characters with diacritics which causes a single Latin character such as ç, à or é to be counted as a Unicode character.

App/src/libs/ReportUtils.js

Lines 2886 to 2890 in d09a1b6

function getCommentLength(textComment) {
return getParsedComment(textComment)
.replace(/[^ -~]/g, '\\u????')
.trim().length;
}

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

Update the regex to exclude latin characters as well while calculating the comment length. This will ensure that characters with diacritics are counted as expected. Note that this will have to be checked with the backend implementation to confirm that it is working correctly.

return getParsedComment(textComment)
-        .replace(/[^ -~]/g, '\\u????')
+        .replace(/[^ -~\p{Script=Latin}]/gu, '\\u????')
       .trim().length;

The regex also has to be extended or updated to exclude other characters such as ", although this is not strictly an ASCII character. These characters will have to be determined, perhaps during the review phase after a PR is created.

What alternative solutions did you explore? (Optional)

If the backend counts characters with diacritics as 6 in length, then we can update the getParsedComment to show the correct "expected count" for presentation on the frontend instead. However, the logic should ideally match whatever the backend implementation is.

@MitchExpensify MitchExpensify added the External Added to denote the issue can be worked on by a contributor label Aug 29, 2023
@melvin-bot melvin-bot bot changed the title Chat - Certain characters are considered as 6 characters within the message box [$1000] Chat - Certain characters are considered as 6 characters within the message box Aug 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

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

@redstar504
Copy link
Contributor

This was intentional due to the bug #13988 which was fixed by PR #14752.

@akinwale
Copy link
Contributor

akinwale commented Aug 29, 2023

This was intentional due to the bug #13988 which was fixed by PR #14752.

Ah, this makes a lot of sense now. I was really curious as to why the length was being calculated this way in the first place. Thanks for the context.

@MitchExpensify
Copy link
Contributor

Ah got it thanks @redstar504 ! Closing in that case

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 Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

5 participants