Skip to content

Commit 08389db

Browse files
committed
harden sanitization
1 parent 6b4d792 commit 08389db

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/marked.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ Lexer.prototype.token = function(src, top) {
434434
: 'html',
435435
pre: !this.options.sanitizer
436436
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
437-
text: cap[0]
437+
text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]
438438
});
439439
continue;
440440
}
@@ -847,7 +847,7 @@ InlineLexer.prototype.output = function(src) {
847847
if (cap = this.rules.text.exec(src)) {
848848
src = src.substring(cap[0].length);
849849
if (this.inRawBlock) {
850-
out += this.renderer.text(cap[0]);
850+
out += this.renderer.text(this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0])) : cap[0]);
851851
} else {
852852
out += this.renderer.text(escape(this.smartypants(cap[0])));
853853
}

0 commit comments

Comments
 (0)