Skip to content

Commit

Permalink
Fix ReDoS with autolink
Browse files Browse the repository at this point in the history
Patterns like <<<<<<<<<<:/:/:/:/:/:/:/:/:/:/ currently exhibit O(n^3) complexity, allowing a 5KB document to take 7174ms to parse. With this change, it drops to O(n^2) and 73ms.
  • Loading branch information
Alcaro authored and ariabuckles committed Sep 26, 2019
1 parent 8a2b428 commit 015a719
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion simple-markdown.js
Expand Up @@ -1316,7 +1316,7 @@ var defaultRules /* : DefaultRules */ = {
},
autolink: {
order: currOrder++,
match: inlineRegex(/^<([^ >]+:\/[^ >]+)>/),
match: inlineRegex(/^<([^: >]+:\/[^ >]+)>/),
parse: function(capture, parse, state) {
return {
type: "link",
Expand Down

0 comments on commit 015a719

Please sign in to comment.