-
Notifications
You must be signed in to change notification settings - Fork 60
fix(urlMatcher): Fix potential ReDoS, thanks to www.HeroDevs.com #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -234,13 +234,14 @@ export class UrlMatcher { | |||||||||||||
| // The regular expression is somewhat complicated due to the need to allow curly braces | ||||||||||||||
| // inside the regular expression. The placeholder regexp breaks down as follows: | ||||||||||||||
| // ([:*])([\w\[\]]+) - classic placeholder ($1 / $2) (search version has - for snake-case) | ||||||||||||||
| // \{([\w\[\]]+)(?:\:\s*( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($4) (search version has - for snake-case | ||||||||||||||
| // \{([\w\[\]]+)(?:\: ... ( ... ))?\} - curly brace placeholder ($3) with optional regexp/type ... ($5) (search version has - for snake-case | ||||||||||||||
| // (?: ... | ... | ... )+ - the regexp consists of any number of atoms, an atom being either | ||||||||||||||
| // [^{}\\]+ - anything other than curly braces or backslash | ||||||||||||||
| // [^{}\\] - anything other than curly braces or backslash | ||||||||||||||
| // \\. - a backslash escape | ||||||||||||||
| // \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms | ||||||||||||||
| const placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g; | ||||||||||||||
| const searchPlaceholder = /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:\s*((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g; | ||||||||||||||
| // \{(?:[^{}\\]|\\.)*\} - a matched set of curly braces containing other atoms | ||||||||||||||
| const placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:(?=(\s*))\4((?:[^{}\\]|\\.|\{(?:[^{}\\]|\\.)*\})+))?\}/g; | ||||||||||||||
| const searchPlaceholder = | ||||||||||||||
| /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:(?=(\s*))\4((?:[^{}\\]|\\.|\{(?:[^{}\\]|\\.)*\})+))?\}/g; | ||||||||||||||
|
Comment on lines
+242
to
+244
|
||||||||||||||
| const placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:(?=(\s*))\4((?:[^{}\\]|\\.|\{(?:[^{}\\]|\\.)*\})+))?\}/g; | |
| const searchPlaceholder = | |
| /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:(?=(\s*))\4((?:[^{}\\]|\\.|\{(?:[^{}\\]|\\.)*\})+))?\}/g; | |
| const placeholder = /([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:(\s*)((?:[^{}\\]|\\.|\{(?:[^{}\\]|\\.)*\})+))?\}/g; | |
| const searchPlaceholder = | |
| /([:]?)([\w\[\].-]+)|\{([\w\[\].-]+)(?:\:(\s*)((?:[^{}\\]|\\.|\{(?:[^{}\\]|\\.)*\})+))?\}/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment describes the pattern as matching a single character, but this doesn't accurately reflect how it's used in the actual regex where it appears within a group with quantifiers like
+. The comment should clarify that this represents a single character atom that can be repeated within the(?:...)+construct.