-
Notifications
You must be signed in to change notification settings - Fork 3k
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 2023-06-28] [$1000] Web - Chat - Inconsistent parsing upon wrapping mentioning message with link #19997
Comments
Triggered auto assignment to @abekkala ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease re-state the problem that we are trying to solve in this issue.Inconsistent parsing upon wrapping mentioning message with link. For example [@test@gmail.com](google.com) is rendered as user mention but input
is rendered as user mention. Both cases shouldn't render user mention. What is the root cause of that problem?First, we apply markdown-link-to-html rule to the input [*@test@gmail.com*](google.com) and output following html converting bold syntax of the link text at the same time inside method modifyTextForUrlLinks <a href="https://google.com" target="_blank" rel="noreferrer noopener"><strong>@test@gmail.com</strong></a> Second, the userMentioins-to-html rule is unexpectedly applied to the output anchor tag above. So the root cause is that the regex of user mention new RegExp(`[\`.a-zA-Z]?@+${CONST.REG_EXP.EMAIL_PART}(?![^<]*(<\\/pre>|<\\/code>|<\\/a>))`, 'gm'), matches <a href="https://google.com" target="_blank" rel="noreferrer noopener"><strong>@test@gmail.com</strong></a> We have a negative lookahead group, the ending group The ending negative lookahead group <strong>@test@gmail.com</strong></a> ![]() So, the ending negative lookahead group can't skip to match the user mention What changes do you think we should make in order to solve the problem?To fix this issue, we can improve the ending negative lookahead group We can use a new ending negative lookahead group (?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>)) where includes two alternative subgroups inside it, The first alternative group
See regex test screenshot ![]() So the new regex of user mention will be new RegExp(`[\`.a-zA-Z]?@+${CONST.REG_EXP.EMAIL_PART}(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>))`, 'gm'), By doing so, input
is translated into html not rendering user mention syntax <a href="https://google.com" target="_blank" rel="noreferrer noopener"><strong>@test@gmail.com</strong></a> and won't break existing unit test cases of Expensify-common lib. The regex of What alternative solutions did you explore? (Optional)N/A |
ProposalPlease re-state the problem that we are trying to solve in this issue.User mention inside a link is parsed inconsistently. What is the root cause of that problem?As you can see below, user mention cannot be parsed when it's inside any html tag.
The main reason of this issue is that we parse link before parsing user mentions What changes do you think we should make in order to solve the problem?I think both should be parsed as normal link. In order to do that We need to change the user-mention rule.
Result19997_mac_chrome.mp4What alternative solutions did you explore? (Optional) |
I even tried copy/paste for |
You need to try with You can check that here in result section |
Hi @abekkala , I think the reproduction steps is not clear enough. We should use underscore
to duplicate it, see demo video Screen.Recording.2023-06-04.at.9.15.52.AM.mov |
@abekkala I can still reproduce it. I think we should reopen this issue. I would also cc @puneetlath as you're most familiar with the mention feature. |
Hm, yes if it's still a bug then let's fix. |
Job added to Upwork: https://www.upwork.com/jobs/~01934ef45479ce0794 |
Current assignee @abekkala is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
Triggered auto assignment to @johnmlee101 ( |
Proposal |
@eh2077 Thanks for the proposal. Your RCA is correct and the fix is acceptable, we can probably go with that as that's how we used to fix a similar issue on |
@s-alves10 Thanks for the proposal. You RCA is not really correct, if it was this issue wouldn't even exist but I see you updated your proposal recently so I assume the RCA is outdated. As for the fix I guess it would work but it's better not to match the regex at all rather than matching and rejecting, or even better avoid any regex changes by altering the order of rules if possible (same note given above). |
@s77rt
But I thought mention-user parsing has some problems and needs to be fixed. In addition, changing rule order may have other issues. That's why I changed the solution. |
@s77rt Thanks for reviewing proposals!
I think, technically, it's possible to achieve it while as
regex: new RegExp(`[\`.a-zA-Z]?@+${CONST.REG_EXP.EMAIL_PART}(?![^<]*(<\\/pre>|<\\/code>|<\\/a>))`, 'gm'), If we want to fix this issue through changing the order, we'll need to figure out a new way to skip parsing mentions within markdown link syntax, like
![]() So, I think re-using the method we have explored previously will be easier. |
@s-alves10 Thanks for the update. I have checked the order of rules. The correct order should be:
This is actually the current order already, except that the link rule calls |
@eh2077 Thanks for the follow up. I have provided some info regarding the order of rules above. I think it's indeed safer and easier to follow the same approach we did with 🎀 👀 🎀 C+ reviewed cc @johnmlee101 |
📣 @eh2077 You have been assigned to this job by @johnmlee101! |
@s77rt @johnmlee101 The PR Expensify/expensify-common#549 for expensify-common repo is ready. Please help to review it when you get time, thanks. |
@johnmlee101, @abekkala, @s77rt, @eh2077 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Not overdue. PR is merged and waiting for deployment. |
@s77rt The PR has been deployed to the production because it occasionally shared the same commit with the other PR #20769. @johnmlee101 pointed it out here #20767 (comment). So, actually, the payment date of this issue should be same as issue #20111. Sorry for the confusion caused! |
Oh right, so we have to track this one manually |
PAYMENTS TO BE MADE JUNE 28
|
@kerupuksambel @eh2077 @s77rt - contract payment offers have been sent! |
@abekkala Accepted. Thank you! |
@eh2077 payment sent and contract ended - thank you! 🎉 |
@abekkala Accepted! |
@s77rt payment sent and contract ended - thank you! 🎉 |
Accepted! @abekkala |
@kerupuksambel payment sent and contract ended - thank you! 🎉 Closing |
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:
Expected Result:
Both message should consistently either changed into link or mention
Actual Result:
While mentioning message without styling turned onto URL, mentioning message with styling turned onto mention-like message, but when clicked turned to be URL as well, and could cause confusion for the user
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.22.0
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
Mention.Formatted.mp4
Recording.2928.mp4
Expensify/Expensify Issue URL:
Issue reported by: @kerupuksambel
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1685404731770449
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: