- Commit
- ff249740f11065eca2ba458b856638e2bfff16f3
- Parent
- 2da7c3f21e2b70cfd08d0f193eeaa6f00e9eb1b8
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
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.
diff --git 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;
+