Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
davisjam committed Apr 16, 2018
1 parent 1ad9ca0 commit fbf93a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,16 +554,19 @@ inline.normal = merge({}, inline);
inline.pedantic = merge({}, inline.normal, {
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
/* Original link re: /^!?\[(label)\]\(\s*<?([\s\S]*?)>?(?:\s+(['"][\s\S]*?['"]))?\s*\)/
* This captures the spec reasonably well but is vulnerable to REDOS.
* Instead we use a custom parser that follows the RegExp.exec semantics. */
link: {
exec: function (s) {
// [TEXT](DESTINATION)
var generalLinkRe = edit(/^!?\[(label)\]\((.*?)\)/)
.replace('label', inline._label)
.getRegex();

function unwrapCarats (str) {
function unwrapAngleBrackets (str) {
if (str.match(/^<.*>$/)) {
str = str.substr(1, str.length - 1);
str = str.slice(1, -1);
}
return str;
}
Expand All @@ -579,7 +582,7 @@ inline.pedantic = merge({}, inline.normal, {
if (m = destinationAndTitleRe.exec(destination)) {
// <destination> -> destination
var dest1 = m[1].trim();
dest1 = unwrapCarats(dest1);
dest1 = unwrapAngleBrackets(dest1);
var title1 = m[2];
return [fullMatch[0], text, dest1, title1];
}
Expand All @@ -588,7 +591,7 @@ inline.pedantic = merge({}, inline.normal, {
if (m = destinationRe.exec(destination)) {
// <destination> -> destination
var dest2 = m[1].trim();
destination = unwrapCarats(dest2);
dest2 = unwrapAngleBrackets(dest2);
var title2 = '';
return [fullMatch[0], text, dest2, title2];
}
Expand Down

0 comments on commit fbf93a8

Please sign in to comment.