From 6b4d7923dbd990cf378914a17c3798bf265a19d8 Mon Sep 17 00:00:00 2001 From: KT Date: Thu, 27 Jun 2019 01:07:13 +0200 Subject: [PATCH] add deprecation warning for sanitize option --- lib/marked.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/marked.js b/lib/marked.js index 86286794e5..bd69ca29d0 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -1536,6 +1536,12 @@ function findClosingBracket(str, b) { return -1; } +function checkSanitizeDeprecation(opt) { + if (opt && opt.sanitize && !opt.silent) { + console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.6.3 and will be removed from the next major version. Please use an external library, e.g. DOMPurify for your sanitization needs."); + } +} + /** * Marked */ @@ -1557,6 +1563,7 @@ function marked(src, opt, callback) { } opt = merge({}, marked.defaults, opt || {}); + checkSanitizeDeprecation(opt); var highlight = opt.highlight, tokens, @@ -1621,6 +1628,7 @@ function marked(src, opt, callback) { } try { if (opt) opt = merge({}, marked.defaults, opt); + checkSanitizeDeprecation(opt); return Parser.parse(Lexer.lex(src, opt), opt); } catch (e) { e.message += '\nPlease report this to https://github.com/markedjs/marked.';