mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Work with phpBB import style links with ellipsis
This commit is contained in:
parent
42dcb77d93
commit
1886ffaff2
4 changed files with 25 additions and 23 deletions
|
@ -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"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -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; i<path.length; i++) {
|
||||||
|
if (path[i][0] === 'a') {
|
||||||
|
var parent = path[path.length - 1],
|
||||||
|
pos = parent.indexOf(node);
|
||||||
|
|
||||||
|
// Just leave the link text
|
||||||
|
if (pos !== -1) {
|
||||||
|
parent[pos] = node[2];
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -182,16 +182,6 @@ Discourse.Markdown = {
|
||||||
if(/^mailto:[\w\.\-@]+/i.test(url)) { return url; }
|
if(/^mailto:[\w\.\-@]+/i.test(url)) { return url; }
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
Checks to see if a name, class or id is allowed in the cooked content
|
|
||||||
|
|
||||||
@method nameIdClassAllowed
|
|
||||||
@param {String} tagName to check
|
|
||||||
@param {String} attribName to check
|
|
||||||
@param {String} value to check
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sanitize text using the sanitizer
|
Sanitize text using the sanitizer
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,10 @@ test("Links", function() {
|
||||||
"It does not consider references that are obviously not URLs");
|
"It does not consider references that are obviously not URLs");
|
||||||
|
|
||||||
cooked("<small>http://eviltrout.com</small>", "<p><small><a href=\"http://eviltrout.com\">http://eviltrout.com</a></small></p>", "Links within HTML tags");
|
cooked("<small>http://eviltrout.com</small>", "<p><small><a href=\"http://eviltrout.com\">http://eviltrout.com</a></small></p>", "Links within HTML tags");
|
||||||
|
|
||||||
|
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");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("simple quotes", function() {
|
test("simple quotes", function() {
|
||||||
|
|
Loading…
Reference in a new issue