-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Copy pathxss.js
61 lines (53 loc) · 1.73 KB
/
xss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(function() {
window.setup_xss_test = function(html, options, done) {
window.xss = function() {
window.clearTimeout(timeout);
complete(new Error('Exploit executed'));
};
var test = setup_test(html, options);
var complete = function(err) {
window.xss = function() {};
done(err);
};
var timeout = window.setTimeout(complete, 75);
return test;
};
describe('XSS', function() {
describe('Raw HTML in original input value', function() {
it('should not trigger exploit', function(done) {
setup_xss_test('<input type="text" value="<img src="x" onerror="xss()">">', {}, done);
});
});
describe('Raw HTML in optgroup label', function() {
it('should not trigger exploit', function(done) {
var test = setup_xss_test('<select><optgroup label="<img src="x" onerror="xss()">"><option>Test</option></optgroup></select>', {}, done);
test.selectize.refreshOptions();
test.selectize.open();
});
});
describe('Raw HTML in option label should not trigger exploit', function() {
it('should not trigger exploit', function(done) {
setup_xss_test('<input type="text" value="">', {
options: [
{value: '1', label: '<img src="x" onerror="xss()">'}
],
items: ['1'],
labelField: 'label',
valueField: 'value'
}, done);
});
});
describe('Raw HTML in option value should not trigger exploit', function() {
it('should not trigger exploit', function(done) {
setup_xss_test('<input type="text" value="">', {
options: [
{value: '<img src="x" onerror="xss()">', label: '1'}
],
items: ['<img src="x" onerror="xss()">'],
labelField: 'label',
valueField: 'value'
}, done);
});
});
});
})();