Skip to content

Commit d038b94

Browse files
committed
Add a test demonstrating the DOM XSS vulnerability
1 parent 83a044b commit d038b94

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ describe('paste-markdown', function () {
3838
assert.include(textarea.value, 'name | origin\n-- | --\nhubot | github\nbender | futurama')
3939
})
4040

41+
it("doesn't execute JavaScript", async function () {
42+
let alertCalled = false
43+
window.secretFunction = function () {
44+
alertCalled = true
45+
}
46+
const data = {
47+
'text/html': `XSS<img/src/onerror=secretFunction()><table>`
48+
}
49+
paste(textarea, data)
50+
51+
await wait(100)
52+
53+
assert.isFalse(alertCalled, 'A XSS was possible as alert was called')
54+
})
55+
4156
it('retains text around tables', async function () {
4257
const data = {
4358
'text/html': `

0 commit comments

Comments
 (0)