From ff249740f11065eca2ba458b856638e2bfff16f3 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 25 Dec 2014 12:55:52 -0700 Subject: Fixed infinite loop in JS parser for link-in-link-in-image. Partially addresses #252. This fixes the infinite loop, and brings the JS parser into agreement with cmark, but both still have bad output in this case, so more work is needed. --- js/lib/inlines.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'js/lib/inlines.js') diff --git a/js/lib/inlines.js b/js/lib/inlines.js index 297d31f..994cc1e 100644 --- a/js/lib/inlines.js +++ b/js/lib/inlines.js @@ -449,6 +449,7 @@ var parseOpenBracket = function(inlines) { var startpos = this.pos; this.pos += 1; + inlines.push(Str("[")); // Add entry to stack for this opener @@ -463,6 +464,7 @@ var parseOpenBracket = function(inlines) { if (this.delimiters.previous !== null) { this.delimiters.previous.next = this.delimiters; } + return true; }; @@ -515,6 +517,7 @@ var parseCloseBracket = function(inlines) { // look through stack of delimiters for a [ or ! opener = this.delimiters; + while (opener !== null) { if (opener.cc === C_OPEN_BRACKET || opener.cc === C_BANG) { break; @@ -599,13 +602,7 @@ var parseCloseBracket = function(inlines) { closer_above = null; while (opener !== null) { if (opener.cc === C_OPEN_BRACKET) { - if (closer_above) { - closer_above.previous = opener.previous; - } else { - this.delimiters = opener.previous; - } - } else { - closer_above = opener; + this.removeDelimiter(opener); // remove this opener from stack } opener = opener.previous; } @@ -826,3 +823,4 @@ function InlineParser(){ } module.exports = InlineParser; + -- cgit v1.2.3