You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-07-21] [$1000] Web - Heading after quote is not rendering #21846
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.32-5 Reproducible in staging?: y Reproducible in production?: y 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
Please re-state the problem that we are trying to solve in this issue.
Heading after quote is not rendering
What is the root cause of that problem?
The root cause of the problem is that \n is deliberately removed after a quote string > quoted string.
A new line is added after the quote message which later got deleted using below code
formatTextForQuote(regex,textToCheck,replacement){if(textToCheck.match(regex)){// Remove '>' and trim each line of quote contentlettextToFormat=textToCheck.split('\n').map(row=>row.substr(4).trim()).join('\n');<======trimishappeninghere// Remove leading and trailing line breakstextToFormat=textToFormat.trim();returnreplacement(textToFormat);}returntextToCheck;}
Input string given to modifyTextForQuote function
> quote\n# heading
so after parsing the text following output is retuned.
<blockquote>quote</blockquote># heading
Now heading regex is looking for # on start of line as below which does not match string <blockquote>quote</blockquote># heading hence it fails to parse heading tag
What changes do you think we should make in order to solve the problem?
Move heading1 rule to be before quote
Modify heading1 rule to not capture the newline: /^# +(?! )((?:(?!<pre>|\n|\r\n).)+)/gm
Add new rule replaceh1br that repalces <br /> next to <h1> tag
{// We're removing <br /> because when <h1> and <br /> occur together, an extra line is added.name: 'replaceh1br',regex: /<\/h1><br\s*[/]?>/gi,replacement: '</h1>',},
Output generated for a given input
Input: '> quote\n# heading'
Output: '<blockquote>quote</blockquote><h1>heading</h1>'
Input: `> a\n# da\n> test`
Output: '<blockquote>a</blockquote><h1>da</h1><blockquote>test</blockquote>'
Input: `>This is a *quote* that started on a new line.\n# Heading 1 should be captured\nHere is a >quote that did not\n`
Output '<blockquote>This is a <strong>quote</strong> that started on a new line.</blockquote><h1>Heading 1 should be captured</h1>Here is a >quote that did not<br/>'
What alternative solutions did you explore? (Optional)
Modify modifyTextForQuote function in order to add new line char when heading is next after the blockquote. It'll let heading rule to parse heading tag as-is
// check if next text chunk is heading tag i.e. starts with # then append new line char \nif(Str.startsWith(textSplitted[i],"# ")){replacedText=`${replacedText}\n`}
After adding \n, parsed output is <blockquote>quote</blockquote><br /><h1>heading</h1> where unnecessary br tag is added between blockquote and h1
Add a new rule to check if a <br /> occurs between blockquote and h1 then remove <br /> tag (we got similar rules replacebr, replacepre). After processing this rule final output is <blockquote>quote</blockquote><h1>heading</h1>.
Code changes required:
// check if next text chunk is heading tag `starts with # ` then append new line char \nif(Str.startsWith(textSplitted[i],"# ")){replacedText=`${replacedText}\n`}
{// We're removing <br /> because when <br /> occur between <blockquote> and <h1>, causing an extra line is added.name: 'replaceBlockquoteBr',regex: /<\/blockquote><br\s*[/]?><h1>/gi,replacement: '</blockquote><h1>',}
Since newline rule replaces \n with <br />. So regex can modified as <\/blockquote><br\s\/><h1>
@kbecciv It actually a bug that went unnoticed. Kindly read through the root cause mentioned in my proposal and you will have an idea why it’s happening.
Heading regex expects ‘#’ on start of the line which never gets captured.
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.40-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-07-21. 🎊
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.
External issue reporter
Contributor that fixed the issue
Contributor+ that helped on the issue and/or PR
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
Merged PR within 3 business days of assignment - 50% bonus
Merged PR more than 9 business days after assignment - 50% penalty
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:
[@s77rt] The PR that introduced the bug has been identified. Link to the PR:
[@s77rt] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@s77rt] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@s77rt] Determine if we should create a regression test for this bug.
[@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@conorpendergrast] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
Activity
melvin-bot commentedon Jun 28, 2023
Triggered auto assignment to @conorpendergrast (
NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details.melvin-bot commentedon Jun 28, 2023
Triggered auto assignment to @lschurr (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jun 28, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Jun 28, 2023
Triggered auto assignment to Design team member for new feature review - @shawnborton (
NewFeature)spcheema commentedon Jun 28, 2023
Proposed solution
Please re-state the problem that we are trying to solve in this issue.
Heading after quote is not rendering
What is the root cause of that problem?
The root cause of the problem is that
\nis deliberately removed after a quote string> quoted string.A new line is added after the quote message which later got deleted using below code
Input string given to
modifyTextForQuotefunctionso after parsing the text following output is retuned.
<blockquote>quote</blockquote># headingNow heading regex is looking for
#on start of line as below which does not match string<blockquote>quote</blockquote># headinghence it fails to parse heading tagWhat changes do you think we should make in order to solve the problem?
heading1rule to be beforequoteheading1rule to not capture the newline:/^# +(?! )((?:(?!<pre>|\n|\r\n).)+)/gmreplaceh1brthat repalces<br />next to<h1>tagOutput generated for a given input
Additional inputs tested
```text > quote # heading > quote ```What alternative solutions did you explore? (Optional)
modifyTextForQuotefunction in order to add new line char when heading is next after theblockquote. It'll let heading rule to parse heading tag as-isAfter adding
\n, parsed output is<blockquote>quote</blockquote><br /><h1>heading</h1>where unnecessarybrtag is added betweenblockquoteandh1<br />occurs betweenblockquoteandh1then remove<br />tag (we got similar rulesreplacebr,replacepre). After processing this rule final output is<blockquote>quote</blockquote><h1>heading</h1>.Code changes required:
Since
newlinerule replaces\nwith<br />. So regex can modified as<\/blockquote><br\s\/><h1>spcheema commentedon Jun 28, 2023
@kbecciv It actually a bug that went unnoticed. Kindly read through the root cause mentioned in my proposal and you will have an idea why it’s happening.
Heading regex expects ‘#’ on start of the line which never gets captured.
90 remaining items
melvin-bot commentedon Jul 14, 2023
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 14, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.40-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-07-21. 🎊
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:
melvin-bot commentedon Jul 14, 2023
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:
spcheema commentedon Jul 15, 2023
@conorpendergrast @s77rt Please consider following timings for bonus eligibility:
E\CommonPR up for reviewE\APPPR up for reviewAfter C++ reviewed & approved, following timeline is waiting for internal reviewer to approve and merge the PR.
Waiting time for
E\CommonPR approval & merge:2 days 9 hours 6 minutes 34 secondsWaiting time for
E\APPPR approval & merge:1 days 11 hours 9 minutes 56 secondsTotal waiting time (internal & merge): 3 days 20hrs approx.
Total time elapsed from issue assigned to second PR merged:
5 days 16 hours 59 minutes 36 secondss77rt commentedon Jul 15, 2023
conorpendergrast commentedon Jul 21, 2023
I will check in on is one, and confirm before paying. I'm OoO on Monday and Tuesday, and will be back to this on Wednesday 26th with confirmation
melvin-bot commentedon Jul 25, 2023
@cead22, @conorpendergrast, @s77rt, @spcheema Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
cead22 commentedon Jul 26, 2023
Not overdue per @conorpendergrast 's update above
conorpendergrast commentedon Jul 26, 2023
@cead22 and I agree with an exception here as the C and C+ acted with urgency.
Everyone has been paid accordingly, and contracts ended. We're all done, thanks!
spcheema commentedon Jul 26, 2023
Thanks @conorpendergrast @cead22 and @s77rt