diff --git a/src/dialects/gruber.js b/src/dialects/gruber.js index ab3326de..ad3a6a76 100644 --- a/src/dialects/gruber.js +++ b/src/dialects/gruber.js @@ -664,11 +664,13 @@ define(['../markdown_helpers', './dialect_helpers', '../parser'], function (Mark return [ consumed, link ]; } - m = text.match(new RegExp("^\\((" + urlRegexp + ")\\)")); - if (m && m[1]) { - consumed += m[0].length; - link = ["link", {href: m[1]}].concat(children); - return [consumed, link]; + if (text.indexOf('(') === 0 && text.indexOf(')') !== -1) { + m = text.match(new RegExp("^\\((" + urlRegexp + ")\\)")); + if (m && m[1]) { + consumed += m[0].length; + link = ["link", {href: m[1]}].concat(children); + return [consumed, link]; + } } // [Alt text][id] diff --git a/test/features/links/missing_end_paren.json b/test/features/links/missing_end_paren.json new file mode 100644 index 00000000..dd6b7b2f --- /dev/null +++ b/test/features/links/missing_end_paren.json @@ -0,0 +1,5 @@ +["html", + ["p", + "an inline link [like this](http://googlewebmastercentral.blogspot.ca/2014/05/understanding-web-pages-better.html can crash V8." + ] +] diff --git a/test/features/links/missing_end_paren.text b/test/features/links/missing_end_paren.text new file mode 100644 index 00000000..a6a5ea3e --- /dev/null +++ b/test/features/links/missing_end_paren.text @@ -0,0 +1 @@ +an inline link [like this](http://googlewebmastercentral.blogspot.ca/2014/05/understanding-web-pages-better.html can crash V8.