Skip to content

Commit

Permalink
upgrade marked out of security vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
susielu committed Jan 5, 2018
1 parent da9ffc7 commit 98bd21c
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 145 deletions.
52 changes: 41 additions & 11 deletions docs/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ block.list = replace(block.list)
('def', '\\n+(?=' + block.def.source + ')')
();

block.blockquote = replace(block.blockquote)
('def', block.def)
();

block._tag = '(?!(?:'
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
Expand Down Expand Up @@ -758,7 +754,7 @@ var inline = {
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
code: /^(`+)([\s\S]*?[^`])\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
Expand Down Expand Up @@ -879,9 +875,11 @@ InlineLexer.prototype.output = function(src) {
if (cap = this.rules.autolink.exec(src)) {
src = src.substring(cap[0].length);
if (cap[2] === '@') {
text = cap[1].charAt(6) === ':'
text = escape(
cap[1].charAt(6) === ':'
? this.mangle(cap[1].substring(7))
: this.mangle(cap[1]);
: this.mangle(cap[1])
);
href = this.mangle('mailto:') + text;
} else {
text = escape(cap[1]);
Expand Down Expand Up @@ -962,7 +960,7 @@ InlineLexer.prototype.output = function(src) {
// code
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.codespan(escape(cap[2], true));
out += this.renderer.codespan(escape(cap[2].trim(), true));
continue;
}

Expand Down Expand Up @@ -1176,10 +1174,13 @@ Renderer.prototype.link = function(href, title, text) {
} catch (e) {
return '';
}
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return '';
}
}
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, href);
}
var out = '<a href="' + href + '"';
if (title) {
out += ' title="' + title + '"';
Expand All @@ -1189,6 +1190,9 @@ Renderer.prototype.link = function(href, title, text) {
};

Renderer.prototype.image = function(href, title, text) {
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, href);
}
var out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
out += ' title="' + title + '"';
Expand Down Expand Up @@ -1395,7 +1399,8 @@ function escape(html, encode) {
}

function unescape(html) {
return html.replace(/&([#\w]+);/g, function(_, n) {
// explicitly match decimal, hex, and named HTML entities
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
n = n.toLowerCase();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {
Expand All @@ -1419,6 +1424,30 @@ function replace(regex, opt) {
};
}

function resolveUrl(base, href) {
if (!baseUrls[' ' + base]) {
// we can ignore everything in base after the last slash of its path component,
// but we might need to add _that_
// https://tools.ietf.org/html/rfc3986#section-3
if (/^[^:]+:\/*[^/]*$/.test(base)) {
baseUrls[' ' + base] = base + '/';
} else {
baseUrls[' ' + base] = base.replace(/[^/]*$/, '');
}
}
base = baseUrls[' ' + base];

if (href.slice(0, 2) === '//') {
return base.replace(/:[^]*/, ':') + href;
} else if (href.charAt(0) === '/') {
return base.replace(/(:\/*[^/]*)[^]*/, '$1') + href;
} else {
return base + href;
}
}
baseUrls = {};
originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;

function noop() {}
noop.exec = noop;

Expand Down Expand Up @@ -1553,7 +1582,8 @@ marked.defaults = {
smartypants: false,
headerPrefix: '',
renderer: new Renderer,
xhtml: false
xhtml: false,
baseUrl: null
};

/**
Expand Down
4 changes: 2 additions & 2 deletions docs/docs.min.js

Large diffs are not rendered by default.

122 changes: 63 additions & 59 deletions indexRollup.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion indexRollup.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 98bd21c

Please sign in to comment.