From d5b526914b9e5b0e97a68130545d5b0b33d7d7ad Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 12 Feb 2014 15:24:03 +0000 Subject: [PATCH] Simplify the regular expression for HTML comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were getting catastrophic backtracking in Chrome for some input texts where the closing “—>” of the comment was omitted. --- .../parsers/wikiparser/rules/commentblock.js | 21 ++++++++++++++++--- .../parsers/wikiparser/rules/commentinline.js | 21 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/commentblock.js b/core/modules/parsers/wikiparser/rules/commentblock.js index fe712f03a..cb1bd1a93 100644 --- a/core/modules/parsers/wikiparser/rules/commentblock.js +++ b/core/modules/parsers/wikiparser/rules/commentblock.js @@ -9,6 +9,8 @@ Wiki text block rule for HTML comments. For example: ``` +Note that the syntax for comments is simplified to an opening "" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html) + \*/ (function(){ @@ -21,13 +23,26 @@ exports.types = {block: true}; exports.init = function(parser) { this.parser = parser; - // Regexp to match - HTML comment regexp by Stephen Ostermiller, http://ostermiller.org/findhtmlcomment.html - this.matchRegExp = /\\r?\n/mg; + this.matchRegExp = /\ ``` +Note that the syntax for comments is simplified to an opening "" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html) + \*/ (function(){ @@ -21,13 +23,26 @@ exports.types = {inline: true}; exports.init = function(parser) { this.parser = parser; - // Regexp to match - HTML comment regexp by Stephen Ostermiller, http://ostermiller.org/findhtmlcomment.html - this.matchRegExp = /\/mg; + this.matchRegExp = /\