From 3a857df0b67c3274720383734e6fa9c2c31f85ca Mon Sep 17 00:00:00 2001 From: Alcaro Date: Wed, 25 Sep 2019 22:55:54 +0200 Subject: [PATCH] Fix ReDoS with autolink 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. --- simple-markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simple-markdown.js b/simple-markdown.js index 3828dcc..80015c5 100644 --- a/simple-markdown.js +++ b/simple-markdown.js @@ -1316,7 +1316,7 @@ var defaultRules /* : DefaultRules */ = { }, autolink: { order: currOrder++, - match: inlineRegex(/^<([^ >]+:\/[^ >]+)>/), + match: inlineRegex(/^<([^: >]+:\/[^ >]+)>/), parse: function(capture, parse, state) { return { type: "link",