Open IuliiaHerets opened 2 days ago
Triggered auto assignment to @garrettmknight (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
Commented on the offending issue.
Job added to Upwork: https://www.upwork.com/jobs/~021856775016601889974
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (External
)
@ntdiary can you take a look at this PR and see if it's causing the problem?
@IuliiaHerets Can you please comment the exact text that was pasted inside the compose box?
@ntdiary can you take a look at this PR and see if it's causing the problem?
@garrettmknight, I think this issue wasn't introduced by that PR. The problem is likely due to performance issues with our input component when parsing url in the text, which causes the app to become unresponsive. This is likely another regular expression catastrophic backtracking problem, similar to #34324 😂
test video:
https://github.com/user-attachments/assets/42caa88d-ebac-4eec-b066-4f86a0f27942
the origin text in the OP:
![test](https://camo.githubusercontent.com/4848d0f965f332077b77a1a0488c3e66b4769032104f4de6890bae218b4add8d/68747470733a2f2f70696373756d2e70686f746f732f69642f313036372f3230302f333030)_test
cc @badeggg
Thanks @ntdiary - we'll solve here then!
@badeggg Posted the exact text that was pasted inside the compose box. It is the same as @ntdiary mentioned
![test](https://camo.githubusercontent.com/4848d0f965f332077b77a1a0488c3e66b4769032104f4de6890bae218b4add8d/68747470733a2f2f70696373756d2e70686f746f732f69642f313036372f3230302f333030 )_test
App stalls when pasting specific text inside the compose box.
We are using few huge regexp when parse the text. Check how big it is, this is the regexp we are using to check image url:
Similar regexp size with 'video' and 'link'. Huge regexp is consuming huge executing resource, which cause the stall.
Though I don't really agree the existence of file tlds.jsx, for the sake of minimal change principle, I suggest change regexp of link/image/video to:
const MARKDOWN_LINK_REGEX = new RegExp(`\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${UrlPatterns.LOOSE_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`, 'gi');
const MARKDOWN_IMAGE_REGEX = new RegExp(`\\!(?:\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)])?\\(${UrlPatterns.LOOSE_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`, 'gi');
const MARKDOWN_VIDEO_REGEX = new RegExp(`\\!(?:\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)])?\\(((${UrlPatterns.LOOSE_URL_REGEX})\\.(?:${Constants.CONST.VIDEO_EXTENSIONS.join('|')}))\\)(?![^<]*(<\\/pre>|<\\/code>))`, 'gi');
That is saying to replace UrlPatterns.MARKDOWN_URL_REGEX
with UrlPatterns.LOOSE_URL_REGEX
, which has a reasonable regexp part.
N/A
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.61-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y Issue was found when executing this PR: https://github.com/Expensify/App/pull/51855 Email or phone of affected tester (no customers): nathanmulugetatesting+2060@gmail.com Issue reported by: Applause Internal Team
Action Performed:
Expected Result:
The text with the image gets sent
Actual Result:
App freezes at first and crashes after a while
Workaround:
Unknown
Platforms:
Screenshots/Videos
https://github.com/user-attachments/assets/27701433-691f-49fe-b122-aec2738e57e5
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @ntdiary