summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-25 12:55:52 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-25 12:55:52 -0700
commitff249740f11065eca2ba458b856638e2bfff16f3 (patch)
tree2b124d0c5d5249f065a33503371be4e3315ff55b /js
parent2da7c3f21e2b70cfd08d0f193eeaa6f00e9eb1b8 (diff)
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.
Diffstat (limited to 'js')
-rw-r--r--js/lib/inlines.js12
1 files changed, 5 insertions, 7 deletions
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;
+