-
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-10-18] [$500] Chat - Adding bracket after link removes link #28344
Comments
Job added to Upwork: https://www.upwork.com/jobs/~01c2d4a022033397cc |
Triggered auto assignment to @Christinadobrzyn ( |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh ( |
ProposalPlease re-state the problem that we are trying to solve in this issueChat - Adding bracket after link removes link What is the root cause of that problem?The does not account for the possibility of multiple closing brackets following the link, causing it to fail in recognizing and properly formatting the link. What changes do you think we should make in order to solve the problem?To solve this problem, we need to modify the regex that is responsible for link formatting to be
With adding +, allows the regex to stop capturing when it encounters multiple closing brackets, thus properly formatting the link, e.g https://new.expensify.com/r/538639631607142) will be rendered as a clickable hyperlink https://new.expensify.com/r/538639631607142 with an extra closing bracket ) following it. What alternative solutions did you explore? (Optional)None |
ProposalPlease re-state the problem that we are trying to solve in this issue.Chat - Adding bracket after link removes link What is the root cause of that problem?The regular expression in App/src/libs/actions/Report.js Line 1141 in e2c9203
What changes do you think we should make in order to solve the problem?Change the regular expression to read till we get the close tag. Basically replace the above line with the below line
Result : Screen.Recording.2023-09-28.at.10.39.05.AM.movWhat alternative solutions did you explore? (Optional)NA |
Thank you for the amazing report @dhanashree-sawant! I can reproduce this and it doesn't look like it's linked to any other jobs. I think this can be external? |
@hoangzinh can you review the above proposals? |
@Christinadobrzyn yes, I will provide updates soon. |
Thank you for your proposal @studentofcoding. I tried to apply your suggestion but it makes current unit tests of expensify-common lib fail. (or if you think current unit tests has wrong expectation atm, please explain the reason). Thanks |
ProposalPlease re-state the problem that we are trying to solve in this issue.Adding bracket after link removes link. What is the root cause of that problem?The root cause of this issue is that, when saving draft, we call method getRemovedMarkdownLinks to extract links which include extra closing parentheses, see method extractLinksInMarkdownComment. Method extractLinksInMarkdownComment uses different way to extract links than method ExpensiMark.replace, see modifyTextForUrlLinks which handles ending closing parentheses. So, method extractLinksInMarkdownComment returns
for draft comment
And the original link therefor is removed by method removeLinksFromHtml. What changes do you think we should make in order to solve the problem?To fix this issue, we should let method extractLinksInMarkdownComment use same logic to extract links as method modifyTextForUrlLinks does. We can convert comment to html and then extract link from const escapedComment = _.escape(comment);
const matches = [...escapedComment.matchAll(MARKDOWN_LINK_REGEX)];
// Element 1 from match is the regex group if it exists which contains the link URLs
const links = _.map(matches, match => Str.sanitizeURL(match[2])); to const html = this.replace(comment);
const matches = [...html.matchAll(new RegExp(`<a href="${MARKDOWN_URL_REGEX}" target="_blank" rel="noreferrer noopener">`, 'gi'))];
// Element 1 from match is the regex group if it exists which contains the link URLs
const links = _.map(matches, match => Str.sanitizeURL(match[1])); The above change passes all test cases of Expensify-common lib. See demo Screen.Recording.2023-10-01.at.7.30.10.PM.movWhat alternative solutions did you explore? (Optional)N/A |
@hoangzinh Hope you had a look at my proposal |
sure thing @kameshwarnayak. I tested with your proposal and it works but I'm checking whether we're fixing it properly or it's just a workaround solution. I will update soon. |
@kameshwarnayak Thanks for your proposal and patience. I tested your proposal #28344 (comment) and it works. But I don't think we have a correct RCA. I'm inclining the RCA of @eh2077 here #28344 (comment). The App/src/libs/actions/Report.js Lines 1161 to 1162 in b403ab5
So I think we should fix our parser |
@eh2077 Thanks for your proposal. Your proposal #28344 (comment) has a correct RCA and your solution looks good to me. It does not only fix the current issue but also potentially fix upcoming issues if we already fixed them in the 🎀👀🎀 C+ reviewed |
Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
Thanks for your detailed review @hoangzinh and attentiveness. I'm inclined to go proposal 2 too as it solves the core issue. Assigning now. |
📣 @hoangzinh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @eh2077 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
📣 @dhanashree-sawant 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app! |
I'll prepare PR for the App to bump the version a little bit later as now we're facing login API failed issue. |
@hoangzinh I found a failed test case of App after applying the fix. The current fix breaks the feature to remove link, like Screen.Recording.2023-10-06.at.4.39.43.PM.movI'll update soon to figure out a way to fix it. |
Please re-state the problem that we are trying to solve in this issue.We fail to remove link after applying the fix. For example, we have following initial draft of a link
Then edit it to
and save it. The text RCAWe apply const htmlString = this.replace(comment); So, we can extract link SolutionA removed link in draft comment doesn't have complete markdown link syntax, We only need to apply const htmlString = this.replace(comment, {filterRules: ['link']}); By doing this, we can pass all tests from both App and expensify-common repo. Also see demo Screen.Recording.2023-10-06.at.5.44.24.PM.mov@hoangzinh @lakchote Please help to review it when you got time. I'll submit another PR to fix it if the above solution makes sense to you. |
Great @eh2077. LGTM ^ |
@hoangzinh PR Expensify/expensify-common#585 is ready for review, thanks. cc @lakchote |
@Luke9389 I was somehow auto-assigned to the app pr for this. I'm assigning you to the App PR |
@hoangzinh I updated and retested PR #28985 and it's ready for review, thanks! |
Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:
On to the next one 🚀 |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.80-3 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-10-18. 🎊 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.
For reference, here are some details about the assignees on this issue:
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:
|
hey @hoangzinh can you let us know if there should be a regression test for this? |
yes, gonna do BZ checklist today |
looks like payment will be the below breakdown - let me know if I'm missing anything Payouts due: Issue Reporter: $50 @dhanashree-sawant Eligible for 50% #urgency bonus? N - based on #28344 (comment) Upwork job is here. |
BugZero Checklist:
|
No regressions so paying this out based on this payment structure. #28344 (comment) No regression test to create |
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:
Expected Result:
Text outside of link format should not affect display of link in reports
Actual Result:
Closing bracket outside of link format makes the link appear as normal text
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.3.74-2
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
windows.chrome.App.removes.link.on.closing.bracket.after.link.mp4
android.chrome.App.removes.link.on.closing.bracket.after.link.mp4
Recording.99.mp4
Screen_Recording_20230928_091753_New.Expensify.1.mp4
braket.mp4
Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695747673717249
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: