Skip to content

fix potential ReDoS in route annotator regex#325

Merged
drwl merged 1 commit intomainfrom
fix/redos-regex-route-annotator
Apr 17, 2026
Merged

fix potential ReDoS in route annotator regex#325
drwl merged 1 commit intomainfrom
fix/redos-regex-route-annotator

Conversation

@OdenTakashi
Copy link
Copy Markdown
Collaborator

Add a \A anchor to the /\s*#/ regex in strip_annotations to avoid unnecessary backtracking from an unanchored pattern.

Without the anchor, the regex engine attempts a match at every position in the string. For example, given " x", it tries position 0, then 1, then 2, and so on. Since each line is already split on newlines, anchoring the pattern to the start of the string does not change the match result, but it does eliminate redundant matching attempts.

Add \A anchor to /\s*#/ regex in strip_annotations to avoid
unnecessary backtracking on unanchored patterns.
@drwl drwl merged commit 602fe73 into main Apr 17, 2026
26 checks passed
@drwl drwl deleted the fix/redos-regex-route-annotator branch April 17, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants