Repository navigation
fix: escaped parentheses in nested labels in no-reversed-media-syntax - #752
Conversation
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review info
π Walkthrough
Merge Risk: βͺ Minimal Β· up to
|
|
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
DMartens
left a comment
There was a problem hiding this comment.
Changes LGTM, thanks.
Only a suggestion to add an additional test case to catch regressions in the future.
| * The nested group is `\((?:\\[\s\S]|[^()\\])*\)`, not `\([\s\S]*\)`, so that it cannot overlap the | ||
| * other alternatives. Overlapping alternatives cause catastrophic backtracking. | ||
| */ | ||
| const reversedPattern = |
There was a problem hiding this comment.
The current regular expression does not match:
(a (b (c\)) d)[x] (removed the first escaping backslash before c)
But the updated version now matches (b (c\)) d)[x] (without (a at the beginning, regex101).
I am unsure how we should handle this / if this is even a bug.
It would be good to add this as a test case, so we can catch regressions if we change the regular expression in the future.
There was a problem hiding this comment.
Good point. After looking into this, it seems consistent with how CommonMark handles regular links: [a [b [c\]] d](x) recognizes only [b [c\]] d](x) as a link, leaving [a as text. So I am not sure this is a bug in this case.
References: link parsing algorithm and Code Explorer.
To clarify:
(c\))is one matching pair of parentheses.(b (c\)) d)is another matching pair of parentheses.- So
(ais left unmatched and ignored in this case.
Iβve also updated the test cases in b5b7b1d.
Prerequisites checklist
AI acknowledgment
What is the purpose of this pull request?
Environment
Which language are you using?
commonmark and gfm
What did you do?
Linted the following Markdown:
What did you expect to happen?
The rule should report reversed syntax and autofix it to:
What actually happened?
No problems were reported.
What changes did you make? (Give an overview)
Fixes a regression introduced in #693 that was overlooked during review. I found it while reviewing #736 (comment), thanks to a comment from CodeRabbit.
The limitation introduced in #693 was that parentheses nested two or more levels deep were no longer reported. However, escaped parentheses should still be reported because they donβt create nested parentheses.
Iβve looked into this carefully, and this change does not introduce any ReDoS-related regressions. The newly added
[\s\S]pattern does not cause catastrophic time complexity.Related Issues
#693
Is there anything you'd like reviewers to focus on?
N/A
Summary by CodeRabbit