From b8f5c21df0f8bdf680626ed4b139c60dc45e790f Mon Sep 17 00:00:00 2001 From: Jens Maier <jens@elberet.de> Date: Sat, 23 Aug 2014 22:46:13 +0200 Subject: [PATCH] Workaround markdown-js links parser bug --- test/javascripts/lib/markdown-test.js.es6 | 4 ++++ vendor/assets/javascripts/better_markdown.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/javascripts/lib/markdown-test.js.es6 b/test/javascripts/lib/markdown-test.js.es6 index 8b513b87028..981d4ecebb9 100644 --- a/test/javascripts/lib/markdown-test.js.es6 +++ b/test/javascripts/lib/markdown-test.js.es6 @@ -138,6 +138,10 @@ test("Links", function() { cooked("[http://google.com ... wat](http://discourse.org)", "<p><a href=\"http://discourse.org\">http://google.com ... wat</a></p>", "it supports linkins within links"); + + cooked("[Link](http://www.example.com) (with an outer \"description\")", + "<p><a href=\"http://www.example.com\">Link</a> (with an outer \"description\")</p>", + "it doesn't consume closing parens as part of the url") }); test("simple quotes", function() { diff --git a/vendor/assets/javascripts/better_markdown.js b/vendor/assets/javascripts/better_markdown.js index 4eee2c61240..5c56a8bde17 100644 --- a/vendor/assets/javascripts/better_markdown.js +++ b/vendor/assets/javascripts/better_markdown.js @@ -1310,7 +1310,7 @@ // back based on if there a matching ones in the url // ([here](/url/(test)) // The parens have to be balanced - var m = text.match( /^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ ); + var m = text.match( /^\s*\([ \t]*([^"'\s]*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ ); if ( m ) { var url = m[1].replace(/\s+$/, ''); consumed += m[0].length;