-
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-01] [$1000] Mentions are being rendered inside of code and codefence #18983
Comments
Triggered auto assignment to @Christinadobrzyn ( |
Job added to Upwork: https://www.upwork.com/jobs/~01408a5d65345b1b64 |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to @anmurali ( |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane ( |
Triggered auto assignment to @stitesExpensify ( |
cc: @bernhardoj @tienifr feel free to submit a proposal because I've seen you both work on markdown issues |
This comment was marked as outdated.
This comment was marked as outdated.
ProposalPlease re-state the problem that we are trying to solve in this issue.Mentions are being rendered inside of code and codefence What is the root cause of that problem?We allow the mention is rendered inside What changes do you think we should make in order to solve the problem?In this modified regular expression, the negative lookahead assertion
is added at the beginning. It ensures that the pattern will not match if it starts with any of the specified strings.
Do same thing at here mention What alternative solutions did you explore? (Optional)we can use this regex if don't want to use negative lookahead
Result |
ProposalPlease re-state the problem that we are trying to solve in this issue.The problem is that when there is a prefix on mentions inside the codeblocks, or multiple mentions, it will break the logic. While the initial bug states that it breaks when other text is included, you can confirm that this happens when:
What is the root cause of that problem?The root of the problem is the Regex code that handles the mentions, specifically the beginning of it:
Along with the above, the regex also doesn't cover multiple mentions inside the same messages. What changes do you think we should make in order to solve the problem?We need to reconfigure the Regex to cover all the possible scenarios, including prefix and multiple mentions. What alternative solutions did you explore? (Optional)The possibility of not using regex on this one, but possibly exclude mentions via components when they are inside the CodeRenderer. |
📣 @Thanos30! 📣
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
ProposalWhat is the root cause of that problem?in order to detect if the mention is inside code or pre tags we're including it to later use it and avoid replacing the mention. but when we include some text before the mention it will match only the mention avoiding the What changes do you think we should make in order to solve the problem?We should update the regex as follows // userMentions
new RegExp(`((`|<code>|<pre>)+(.|\\n)*)?[\`.a-zA-Z]?@+${CONST.REG_EXP.EMAIL_PART}`, 'gm')
//hereMentions
/((`|<code>|<pre>)+(.|\n)*)?[`.a-zA-Z]?@here\b/gm Explanation: adding ![]() Result![]() What alternative solutions did you explore? (Optional)cc @puneetlath |
ProposalPlease re-state the problem that we are trying to solve in this issue.We don't want a mention to be rendered inside a code block or code fence. What is the root cause of that problem?Currently, to prevent that, we check if the matches string contains either However, if the mention is not at the start of the string, it won't be included into the regex match. Notice that we accept What changes do you think we should make in order to solve the problem?The current validation is not good to prevent mention inside a code block/fence. The better way is to not match the mention inside code block/fence in the first place. To do that,
This new added regex already being used in some rules, for example this one: Why also add anchor tag to solve this issue #18857. I added a proposal on that issue with the same solution. @rushatgabhane thx for tagging, btw |
@puneetlath I like @bernhardoj's proposal C+ reviewed 🎀 👀 🎀 |
Any comment on my proposal? @rushatgabhane |
@chiragxarora what? howw |
It's not a duplicate exactly. It's just that the solution of this issue solves both of the issues. Both of them come down to the regex code the solution changes. |
issue is about mentions being rendered inside codeblock. |
I'd still call it dupe because main BUG is about mentions rendering inside codeblock. I don't see how these appear different |
I think @chiragxarora said this one is a dupe because this issue #18893 is created earlier but we handled this one first, which could be confusing for most of us 😄. |
that is also true but it's dupe for the other reason too which I mentioned above |
I think that's already been handled @chiragxarora |
@puneetlath I think I already reported this in #18167 (comment). |
App PR is ready for review |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.17-5 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 2023-06-01. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Upwork contracts sent. @rushatgabhane friendly reminder about the checklist! |
@rushatgabhane friendly reminder about the checklist so that I can pay this out tomorrow. |
|
All paid. Thanks everyone! |
Mentions are not supposed to get rendered inside codeblocks and codefences. This is working as expected when the mention is the only text inside the code, however, it doesn't work when mentions are included with other text.
The typed text for these four was:
All of these should get rendered without the
<mention-user>
or<mention-here>
tags, but 2 and 4 are getting rendered with those tags.cc @getusha happy to give you the first shot at this since you implemented the original.
Upwork Automation - Do Not Edit
Issue reporter @dhanashree-sawant
Also reported by @parasharrajat
The text was updated successfully, but these errors were encountered: