mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 01:17:16 +08:00
SECURITY: fix XSS in link's href
This commit is contained in:
@ -401,14 +401,20 @@ test("URLs in BBCode tags", function() {
|
||||
});
|
||||
|
||||
test("urlAllowed", function() {
|
||||
var urlAllowed = Discourse.Markdown.urlAllowed;
|
||||
|
||||
var allowed = function(url, msg) {
|
||||
equal(Discourse.Markdown.urlAllowed(url), url, msg);
|
||||
equal(urlAllowed(url), url, msg);
|
||||
};
|
||||
|
||||
allowed("/foo/bar.html", "allows relative urls");
|
||||
allowed("http://eviltrout.com/evil/trout", "allows full urls");
|
||||
allowed("https://eviltrout.com/evil/trout", "allows https urls");
|
||||
allowed("//eviltrout.com/evil/trout", "allows protocol relative urls");
|
||||
|
||||
equal(urlAllowed("http://google.com/test'onmouseover=alert('XSS!');//.swf"),
|
||||
"http://google.com/test'onmouseover=alert('XSS!');//.swf",
|
||||
"escape single quotes");
|
||||
});
|
||||
|
||||
test("images", function() {
|
||||
|
Reference in New Issue
Block a user