App: [HOLD for payment 2023-08-01] [$1000] App allows to add link in code block and does not display the same on copy and send

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. Open the app
  2. Open any report
  3. Send link in following format : Test
  4. Observe that it displays link inside code block (till now, we have intentionally made sure to not display link in code block)
  5. Hover and click on copy to clipboard
  6. Paste in compose box and send
  7. Observe that now, it does not display link in code block

Expected Result:

App should not display link inside code block and maintain same display format on copy to clipboard and send again as message

Actual Result:

App displays link inside code block if sent in specific format and on copy to clipboard and sending as normal message, it does not maintain the format

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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.38-2 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

https://github.com/Expensify/App/assets/43996225/ece2ab63-c0c2-4f1c-a65c-b1632dee93f1

https://github.com/Expensify/App/assets/43996225/96e0f0fa-9c89-46c4-9c95-684095a34b51

Expensify/Expensify Issue URL: Issue reported by: @dhanashree-sawant Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1688796230285319

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f921043b5d238f9f
  • Upwork Job ID: 1678721695254556672
  • Last Price Increase: 2023-07-11

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 38 (20 by maintainers)

Most upvoted comments

Thanks @thesahindia - let me know if you need any help with the payment stuff through New Expensify

Created Regression Test - https://github.com/Expensify/Expensify/issues/306418 Closing this GH

@thesahindia paid through NewExpensify $1000 + $500 speed bonus

Actually I haven’t got paid yet. I still need to add my bank account at old dot (having some issues). But this issue is in my list so we can close it, I will request payment soon.

Sorry for the delay here are the steps -

  1. Go to a chat and add following comment
[```code```](google.com)
  1. Verify that only code is displayed as code block and link google.com is displayed as auto link.
  2. Edit the comment and verify the initial draft is
Screenshot 2023-08-07 at 2 02 31 AM

Paying out in Upwork - https://www.upwork.com/jobs/~01f921043b5d238f9f

@dhanashree-sawant paid through Upwork for reporting the bug $250 @eh2077 paid through Upwork for contributor work $1000 + $500 speed bonus @thesahindia paid through NewExpensify $1000 + $500 speed bonus

Thanks @zanyrenney, @Christinadobrzyn, Invite accepted.

Invites have been sent to @eh2077 @thesahindia and @dhanashree but we are still waiting on them to accept. The final step is payment. I am going OOO so please can you pay out these? Thank you BZ team member!

@hayata-suenaga I commented in the PR https://github.com/Expensify/expensify-common/pull/558 and explained why fixing this issue won’t conflict with the direction of fixing the issue mentioned by @parasharrajat

Proposal

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

App allows to add link in code block and does not display the same on copy and send.

What is the root cause of that problem?

The following markdown input

[```code```](google.com)

is translated into html

<a href="https://google.com" target="_blank" rel="noreferrer noopener"><pre>code</pre></a>

from frontend by method ExpensiMark.replace applying code fence rule and link rule.

The backend corrects the above html into following html

<a href="https://google.com" target="_blank" rel="noreferrer noopener"></a><pre><a href="https://google.com" target="_blank" rel="noreferrer noopener">code</a></pre><a href="https://google.com" target="_blank" rel="noreferrer noopener"></a>

which is translated into following markdown when clicking to edit the comment

```
[code](https://google.com)
```

Note the starting and ending anchor tag, <a href="https://google.com" target="_blank" rel="noreferrer noopener"></a>, are same and translated into empty string.

So, the root cause of this issue is that the link rule doesn’t skip to translate markdown link syntax if its alias text inside [] contains code fence tag <pre>.

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

To fix this issue, we should avoid translating link markdown syntax if its alias text part contains <pre> tag.

To achieve it, we can change following condition

https://github.com/Expensify/expensify-common/blob/d636fef3f22b4e5fcf61333ddc89a5d2e08cacc9/lib/ExpensiMark.js#L454

of method modifyTextForUrlLinks by checking if the alias text part, match[1], includes <pre> tags

if (abort || match[1].includes('<pre>')) {

to skip replacing link syntax to html.

What alternative solutions did you explore? (Optional)

N/A