fix: enhance link title parsing with hyphens and underscores in URL's - #41739
fix: enhance link title parsing with hyphens and underscores in URL's#41739Vaishali021103 wants to merge 1 commit into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughThe parser now uses link-title-specific emphasis rules that preserve ChangesLink Title Parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Proposed changes (including videos or screenshots)
This PR fixes URL and markdown-link parsing for cases where the URL or query string contains underscores and hyphenated values, without breaking valid host parsing or treating underscores as invalid emphasis boundaries.
The fix updates the parser rules in the message-parser grammar to allow valid URL paths and query parameters containing underscores while still rejecting malformed underscore-prefixed domains. It also adds regression coverage for real-world link cases such as:
[testwithatextcontainingan_here](http://example.com?a_param)[test-with-a-text-containing-an_here](http://example.com?param=my_value)http://te_st.comhttps://developer.rocket.chat?query=query_with_underscorehttps://developer.rocket.chat/path_with_underscoreThis ensures markdown links remain parsed correctly in messages containing mixed hyphen/underscore URL content.
Issue(s)
Fixes #41725 URL parsing bug for markdown links and autolinks containing underscores in the path/query string and mixed hyphen/underscore link titles.
Steps to test or reproduce
[testwithatextcontainingan_here](http://example.com?a_param)[test-with-a-text-containing-an_here](http://example.com?param=my_value)https://developer.rocket.chat/path_with_underscorehttps://developer.rocket.chat?query=query_with_underscoreFurther comments
This is a targeted parser fix in the message parser grammar and is covered by regression tests in the package’s link and URL test suites. The change is intentionally narrow: it preserves existing parsing behavior for valid URLs while avoiding false positives caused by underscores in host/path contexts.