Skip to content

Commit 6b4d792

Browse files
committed
add deprecation warning for sanitize option
1 parent 0b7fc5e commit 6b4d792

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/marked.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,12 @@ function findClosingBracket(str, b) {
15361536
return -1;
15371537
}
15381538

1539+
function checkSanitizeDeprecation(opt) {
1540+
if (opt && opt.sanitize && !opt.silent) {
1541+
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.");
1542+
}
1543+
}
1544+
15391545
/**
15401546
* Marked
15411547
*/
@@ -1557,6 +1563,7 @@ function marked(src, opt, callback) {
15571563
}
15581564

15591565
opt = merge({}, marked.defaults, opt || {});
1566+
checkSanitizeDeprecation(opt);
15601567

15611568
var highlight = opt.highlight,
15621569
tokens,
@@ -1621,6 +1628,7 @@ function marked(src, opt, callback) {
16211628
}
16221629
try {
16231630
if (opt) opt = merge({}, marked.defaults, opt);
1631+
checkSanitizeDeprecation(opt);
16241632
return Parser.parse(Lexer.lex(src, opt), opt);
16251633
} catch (e) {
16261634
e.message += '\nPlease report this to https://github.com/markedjs/marked.';

0 commit comments

Comments
 (0)