From 99af518c86592c8953a3fc0d9045ed6ae24b2d5a Mon Sep 17 00:00:00 2001 From: Michael Sommerville Date: Thu, 23 Jun 2016 16:01:36 +0100 Subject: [PATCH] Expose potentiallyUnsafe function in HtmlRender prototype --- lib/render/html.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/render/html.js b/lib/render/html.js index a03a4062..b53fddd8 100644 --- a/lib/render/html.js +++ b/lib/render/html.js @@ -8,7 +8,7 @@ var reHtmlTag = /\<[^>]*\>/; var reUnsafeProtocol = /^javascript:|vbscript:|file:|data:/i; var reSafeDataProtocol = /^data:image\/(?:png|gif|jpeg|webp)/i; -var potentiallyUnsafe = function(url) { +function potentiallyUnsafe(url) { return reUnsafeProtocol.test(url) && !reSafeDataProtocol.test(url); }; @@ -65,7 +65,7 @@ function linebreak() { function link(node, entering) { var attrs = this.attrs(node); if (entering) { - if (!(this.options.safe && potentiallyUnsafe(node.destination))) { + if (!(this.options.safe && this.potentiallyUnsafe(node.destination))) { attrs.push(['href', esc(node.destination, true)]); } if (node.title) { @@ -81,7 +81,7 @@ function image(node, entering) { if (entering) { if (this.disableTags === 0) { if (this.options.safe && - potentiallyUnsafe(node.destination)) { + this.potentiallyUnsafe(node.destination)) { this.lit('