mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Markdown parser: empty links and bbcode parsed as link refs
This commit is contained in:
parent
6d1be665a1
commit
9be5c98c8c
2 changed files with 7 additions and 1 deletions
|
@ -119,6 +119,10 @@ test("Links", function() {
|
|||
|
||||
cooked("[3]: http://eviltrout.com", "", "It doesn't autolink markdown link references");
|
||||
|
||||
cooked("[]: http://eviltrout.com", "<p>[]: <a href=\"http://eviltrout.com\">http://eviltrout.com</a></p>", "It doesn't accept empty link references");
|
||||
|
||||
cooked("[b]label[/b]: description", "<p><span class=\"bbcode-b\">label</span>: description</p>", "It doesn't accept BBCode as link references");
|
||||
|
||||
cooked("http://discourse.org and http://discourse.org/another_url and http://www.imdb.com/name/nm2225369",
|
||||
"<p><a href=\"http://discourse.org\">http://discourse.org</a> and " +
|
||||
"<a href=\"http://discourse.org/another_url\">http://discourse.org/another_url</a> and " +
|
||||
|
|
4
vendor/assets/javascripts/better_markdown.js
vendored
4
vendor/assets/javascripts/better_markdown.js
vendored
|
@ -1135,7 +1135,7 @@
|
|||
},
|
||||
|
||||
referenceDefn: function referenceDefn( block, next) {
|
||||
var re = /^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*)\3|\((.*?)\)))?\n?/;
|
||||
var re = /^\s*\[([^\[\]]+)\]:\s*(\S+)(?:\s+(?:(['"])(.*)\3|\((.*?)\)))?\n?/;
|
||||
// interesting matches are [ , ref_id, url, , title, title ]
|
||||
|
||||
if ( !block.match(re) )
|
||||
|
@ -1295,6 +1295,8 @@
|
|||
return [ res[0] + 1, text.charAt(0) ].concat(res[2]);
|
||||
}
|
||||
|
||||
if ( res[0] == 1 ) { return [ 2, "[]" ]; } // empty link found.
|
||||
|
||||
var consumed = 1 + res[ 0 ],
|
||||
children = res[ 1 ],
|
||||
link,
|
||||
|
|
Loading…
Reference in a new issue