From 639f41521161f01b1204b0d23064ac92dd37beef Mon Sep 17 00:00:00 2001 From: Matt Austin Date: Thu, 19 Jan 2017 15:03:37 -0800 Subject: [PATCH] added data: link fix to prevent xss --- lib/marked.js | 2 +- test/tests/links.sanitize.html | 1 + test/tests/links.sanitize.text | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index 9f1584bb3b..2696019cda 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -875,7 +875,7 @@ Renderer.prototype.link = function(href, title, text) { } catch (e) { return ''; } - if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) { + if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) { return ''; } } diff --git a/test/tests/links.sanitize.html b/test/tests/links.sanitize.html index 5a5a973589..58d6f5ea38 100644 --- a/test/tests/links.sanitize.html +++ b/test/tests/links.sanitize.html @@ -1,4 +1,5 @@

+

\ No newline at end of file diff --git a/test/tests/links.sanitize.text b/test/tests/links.sanitize.text index c2158fc82e..ba5d09fed7 100644 --- a/test/tests/links.sanitize.text +++ b/test/tests/links.sanitize.text @@ -4,4 +4,6 @@ [URL](javascript:alert(1)) -[URL](javascript:document;alert(1)) \ No newline at end of file +[URL](javascript:document;alert(1)) + +[URL](data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K) \ No newline at end of file