From f149969c834f9a85c9344590c81b824d09bba2af Mon Sep 17 00:00:00 2001 From: Gemini Wen Date: Fri, 6 Jan 2017 22:05:13 +0800 Subject: [PATCH 1/4] add comment whitelist --- src/Parser.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Parser.coffee b/src/Parser.coffee index 6be3b42..be1e763 100644 --- a/src/Parser.coffee +++ b/src/Parser.coffee @@ -162,7 +162,6 @@ class Parser # release holder releaseHolder: (text, clearHolders = yes) -> deep = 0 - while (text.indexOf "\r") >= 0 and deep < 10 text = str_replace (array_keys @holders), (array_values @holders), text deep += 1 @@ -199,6 +198,10 @@ class Parser else htmlspecialchars matches[0] + # comment + text = text.replace //ig, (matches...) => + @makeHolder matches[0] + text = str_replace ['<', '>'], ['<', '>'], text # footnote @@ -251,7 +254,6 @@ class Parser text = @call 'afterParseInlineBeforeRelease', text text = @releaseHolder text, clearHolders - text = @call 'afterParseInline', text text From 1a486c960e2d1c4d2a376941b3d2ae1e59de9523 Mon Sep 17 00:00:00 2001 From: Gemini Wen Date: Fri, 6 Jan 2017 22:51:45 +0800 Subject: [PATCH 2/4] rebuild --- Parser.js | 9 ++++++++- cli.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Parser.js b/Parser.js index 4a4a261..4baab8b 100644 --- a/Parser.js +++ b/Parser.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.1 +// Generated by CoffeeScript 1.12.2 (function() { var Parser, slice = [].slice; @@ -248,6 +248,13 @@ } }; })(this)); + text = text.replace(//ig, (function(_this) { + return function() { + var matches; + matches = 1 <= arguments.length ? slice.call(arguments, 0) : []; + return _this.makeHolder(matches[0]); + }; + })(this)); text = str_replace(['<', '>'], ['<', '>'], text); text = text.replace(/\[\^((?:[^\]]|\\\]|\\\[)+?)\]/g, (function(_this) { return function() { diff --git a/cli.js b/cli.js index 47a95e0..65b841c 100644 --- a/cli.js +++ b/cli.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.12.1 +// Generated by CoffeeScript 1.12.2 (function() { var Fs, Parser, buff, file, parser, read; From 1987881c02a33c68c80f0fe9df19316362c40ec3 Mon Sep 17 00:00:00 2001 From: Gemini Wen Date: Fri, 6 Jan 2017 22:55:21 +0800 Subject: [PATCH 3/4] allow empty comment --- src/Parser.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.coffee b/src/Parser.coffee index be1e763..6d7b59f 100644 --- a/src/Parser.coffee +++ b/src/Parser.coffee @@ -199,7 +199,7 @@ class Parser htmlspecialchars matches[0] # comment - text = text.replace //ig, (matches...) => + text = text.replace //ig, (matches...) => @makeHolder matches[0] text = str_replace ['<', '>'], ['<', '>'], text From 4af3fcb9744ed084241aa69e59d5b004b13d653f Mon Sep 17 00:00:00 2001 From: Gemini Wen Date: Fri, 6 Jan 2017 23:02:27 +0800 Subject: [PATCH 4/4] rebuild --- Parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parser.js b/Parser.js index 4baab8b..7c9b016 100644 --- a/Parser.js +++ b/Parser.js @@ -248,7 +248,7 @@ } }; })(this)); - text = text.replace(//ig, (function(_this) { + text = text.replace(//ig, (function(_this) { return function() { var matches; matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];