From 9c91e40e3b10ce332599a2d4ccc22b2e78d6ca67 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 5 Jun 2019 11:04:38 -0500 Subject: [PATCH] revert #1464 --- lib/marked.js | 40 +++++---------------------- test/specs/redos/nested_blockquote.js | 4 --- 2 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 test/specs/redos/nested_blockquote.js diff --git a/lib/marked.js b/lib/marked.js index 6964429d35..86286794e5 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -200,9 +200,7 @@ Lexer.prototype.token = function(src, top) { l, isordered, istask, - ischecked, - blockquote, - count; + ischecked; while (src) { // newline @@ -308,26 +306,16 @@ Lexer.prototype.token = function(src, top) { type: 'blockquote_start' }); - blockquote = cap[0].replace(/^ *> ?/gm, ''); - count = 1; - while (blockquote.match(/^ {0,3}>/)) { - count++; - this.tokens.push({ - type: 'blockquote_start' - }); - blockquote = blockquote.replace(/^ *> ?/gm, ''); - } + cap = cap[0].replace(/^ *> ?/gm, ''); // Pass `top` to keep the current // "toplevel" state. This is exactly // how markdown.pl works. - this.token(blockquote, top); + this.token(cap, top); - for (i = 0; i < count; i++) { - this.tokens.push({ - type: 'blockquote_end' - }); - } + this.tokens.push({ + type: 'blockquote_end' + }); continue; } @@ -1253,27 +1241,13 @@ Parser.prototype.tok = function() { return this.renderer.table(header, body); } case 'blockquote_start': { - var count = 1; - while (this.peek() && this.peek().type === 'blockquote_start') { - this.next(); - count++; - } - body = ''; while (this.next().type !== 'blockquote_end') { body += this.tok(); } - while (this.peek() && this.peek().type === 'blockquote_end') { - this.next(); - } - - for (i = 0; i < count; i++) { - body = this.renderer.blockquote(body); - } - - return body; + return this.renderer.blockquote(body); } case 'list_start': { body = ''; diff --git a/test/specs/redos/nested_blockquote.js b/test/specs/redos/nested_blockquote.js deleted file mode 100644 index 11e5f5f9d9..0000000000 --- a/test/specs/redos/nested_blockquote.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - markdown: '>'.repeat(5000), - html: '
'.repeat(5000) + '
'.repeat(5000) -};