Skip to content

Commit

Permalink
sanitizer. see #468.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed May 8, 2015
1 parent e91a45c commit 7dca210
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,11 @@ Lexer.prototype.token = function(src, top, bq) {
if (cap = this.rules.html.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: this.options.sanitize && typeof(this.options.sanitize) !== 'function'
type: this.options.sanitize
? 'paragraph'
: 'html',
pre: !this.options.sanitize && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
pre: !this.options.sanitizer
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: cap[0]
});
continue;
Expand Down Expand Up @@ -606,8 +607,8 @@ InlineLexer.prototype.output = function(src) {
}
src = src.substring(cap[0].length);
out += this.options.sanitize
? typeof(this.options.sanitize) === 'function'
? this.options.sanitize(cap[0])
? this.options.sanitizer
? this.options.sanitizer(cap[0])
: escape(cap[0])
: cap[0]
continue;
Expand Down Expand Up @@ -713,7 +714,7 @@ InlineLexer.prototype.outputLink = function(cap, link) {
InlineLexer.prototype.smartypants = function(text) {
if (!this.options.smartypants) return text;
return text
// em-dashes
// em-dashes
.replace(/---/g, '\u2014')
// en-dashes
.replace(/--/g, '\u2013')
Expand Down Expand Up @@ -1241,6 +1242,7 @@ marked.defaults = {
breaks: false,
pedantic: false,
sanitize: false,
sanitizer: null,
mangle: true,
smartLists: false,
silent: false,
Expand Down

0 comments on commit 7dca210

Please sign in to comment.