From 6c9c8026001e37735ac6bc95a5585b8d8180d905 Mon Sep 17 00:00:00 2001 From: Christopher Joslyn Date: Sun, 25 Sep 2016 09:16:07 -0400 Subject: [PATCH] Prevent text with opening but no closing angle bracket from being parsed as tag. fixes #813 --- lib/marked.js | 2 +- test/new/angle-with-autolink.html | 7 +++++++ test/new/angle-with-autolink.text | 7 +++++++ test/tests/angle-with-autolink.html | 7 +++++++ test/tests/angle-with-autolink.text | 7 +++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/new/angle-with-autolink.html create mode 100644 test/new/angle-with-autolink.text create mode 100644 test/tests/angle-with-autolink.html create mode 100644 test/tests/angle-with-autolink.text diff --git a/lib/marked.js b/lib/marked.js index 9f1584bb3b..a0d1a3ccdc 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -451,7 +451,7 @@ var inline = { escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, autolink: /^<([^ >]+(@|:\/)[^ >]+)>/, url: noop, - tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/, + tag: /^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^<'">])*?>/, link: /^!?\[(inside)\]\(href\)/, reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/, diff --git a/test/new/angle-with-autolink.html b/test/new/angle-with-autolink.html new file mode 100644 index 0000000000..ba2fbbecf5 --- /dev/null +++ b/test/new/angle-with-autolink.html @@ -0,0 +1,7 @@ +

Open angle bracket with link:

+ +

<http://example.com

+ +

With space: < http://example.com

+ +

With content: <1 http://example.com

diff --git a/test/new/angle-with-autolink.text b/test/new/angle-with-autolink.text new file mode 100644 index 0000000000..4fad3d24ba --- /dev/null +++ b/test/new/angle-with-autolink.text @@ -0,0 +1,7 @@ +Open angle bracket inline with link: + +< + +With space: < + +With content: <1 diff --git a/test/tests/angle-with-autolink.html b/test/tests/angle-with-autolink.html new file mode 100644 index 0000000000..ba2fbbecf5 --- /dev/null +++ b/test/tests/angle-with-autolink.html @@ -0,0 +1,7 @@ +

Open angle bracket with link:

+ +

<http://example.com

+ +

With space: < http://example.com

+ +

With content: <1 http://example.com

diff --git a/test/tests/angle-with-autolink.text b/test/tests/angle-with-autolink.text new file mode 100644 index 0000000000..4fad3d24ba --- /dev/null +++ b/test/tests/angle-with-autolink.text @@ -0,0 +1,7 @@ +Open angle bracket inline with link: + +< + +With space: < + +With content: <1