From 1886ffaff2e51a2296480c8c1cf42dd8bdb05238 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 14 Jul 2014 14:26:48 -0400 Subject: [PATCH] FIX: Work with phpBB import style links with ellipsis --- .../discourse/dialects/anchor_dialect.js | 13 ------------ .../dialects/nested_link_dialects.js | 21 +++++++++++++++++++ .../javascripts/discourse/lib/markdown.js | 10 --------- test/javascripts/lib/markdown_test.js | 4 ++++ 4 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 app/assets/javascripts/discourse/dialects/anchor_dialect.js create mode 100644 app/assets/javascripts/discourse/dialects/nested_link_dialects.js diff --git a/app/assets/javascripts/discourse/dialects/anchor_dialect.js b/app/assets/javascripts/discourse/dialects/anchor_dialect.js deleted file mode 100644 index a63762417..000000000 --- a/app/assets/javascripts/discourse/dialects/anchor_dialect.js +++ /dev/null @@ -1,13 +0,0 @@ -// prevent XSS -Discourse.Dialect.on('parseNode', function (event) { - var node = event.node; - - if (node[0] === 'a') { - var attributes = node[1]; - if (attributes["href"]) { - if (!Discourse.Markdown.urlAllowed(attributes["href"])) { - delete attributes["href"]; - } - } - } -}); diff --git a/app/assets/javascripts/discourse/dialects/nested_link_dialects.js b/app/assets/javascripts/discourse/dialects/nested_link_dialects.js new file mode 100644 index 000000000..1de2a1fbd --- /dev/null +++ b/app/assets/javascripts/discourse/dialects/nested_link_dialects.js @@ -0,0 +1,21 @@ +Discourse.Dialect.on('parseNode', function (event) { + var node = event.node, + path = event.path; + + if (node[0] === 'a') { + + // It's invalid HTML to nest a link within another so strip it out. + for (var i=0; ihttp://eviltrout.com", "

http://eviltrout.com

", "Links within HTML tags"); + + cooked("[http://google.com ... wat](http://discourse.org)", + "

http://google.com ... wat

", + "it supports linkins within links"); }); test("simple quotes", function() {