From 0824f93443bd315297fd324ee5ef28f98c5fd0ef Mon Sep 17 00:00:00 2001 From: mloginov Date: Wed, 21 Jan 2015 12:56:47 +0300 Subject: [PATCH] tags whitelist support --- lib/marked.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/marked.js b/lib/marked.js index 142eccf00a..dd2fb6a105 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -605,9 +605,14 @@ InlineLexer.prototype.output = function(src) { this.inLink = false; } src = src.substring(cap[0].length); - out += this.options.sanitize - ? escape(cap[0]) - : cap[0]; + + var allowedTags = this.options.allowedTags; + var exp = new RegExp('<(\/?)\\s*(' + allowedTags + ')([^>]*)>', 'g'); + var isTagInWhitelist = allowedTags && !!cap[0].match(exp); + + out += this.options.sanitize && !isTagInWhitelist + ? escape(cap[0]) + : cap[0]; continue; }