mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
tests for XSS injection in tooltips
This commit is contained in:
parent
a6d50d1ff7
commit
9f4e814dbc
1 changed files with 25 additions and 0 deletions
25
test/javascripts/lib/tooltip-test.js.es6
Normal file
25
test/javascripts/lib/tooltip-test.js.es6
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { registerTooltip } from "discourse/lib/tooltip";
|
||||
|
||||
// prettier-ignore
|
||||
QUnit.module("lib:tooltip", {
|
||||
beforeEach() {
|
||||
fixture().html(
|
||||
"<a class='test-link' data-tooltip='XSS<s onmouseover\=alert(document.domain)>XSS'>test</a>"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("it prevents XSS injection", assert => {
|
||||
const $testLink = fixture(".test-link");
|
||||
registerTooltip($testLink);
|
||||
$testLink.click();
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
fixture(".tooltip-content")
|
||||
.html()
|
||||
.trim(),
|
||||
"XSS<s onmouseover=alert(document.domain)>XSS"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue