File: sanitizer-javascript-url.html

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (168 lines) | stat: -rw-r--r-- 3,322 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<head>
<title>Testcases for handling javascript: URL attributes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/html5lib-testcase-support.js"></script>

<script id="built-in-navigating-url-attributes-list" type="html5lib-testcases">
#data
<a href="javascript:alert(1)"></a>
#document
| <a>

#data
<area href="javascript:alert(1)"></area>
#document
| <area>

#data
<base href="javascript:alert(1)"></base>
#document
| <base>

#data
<button formaction="javascript:alert(1)"></button>
#document
| <button>

#data
<form action="javascript:alert(1)"></form>
#document
| <form>

#data
<input formaction="javascript:alert(1)"></input>
#document
| <input>

#data
<svg><a href="javascript:alert(1)"></a></svg>
#document
| <svg svg>
|   <svg a>

#data
<svg><a xlink:href="javascript:alert(1)"></a></svg>
#document
| <svg svg>
|   <svg a>
</script>

<script id="mathml" type="html5lib-testcases">
#data
<math><mrow href="javascript:alert(1)"></mrow></math>
#document
| <math math>
|   <math mrow>

#data
<math><msqrt href="javascript:alert(1)"></msqrt></math>
#document
| <math math>
|   <math msqrt>

#data
<math><mtext href="javascript:alert(1)">Test</mtext></math>
#document
| <math math>
|   <math mtext>
|     "Test"
</script>

<script id="built-in-animating-url-attributes-list" type="html5lib-testcases">
#data
<svg><animate attributeName="href"></svg>
#document
| <svg svg>
|   <svg animate>

#data
<svg><animate attributeName="xlink:href"></svg>
#document
| <svg svg>
|   <svg animate>


#data
<svg><animateMotion attributeName="href"></svg>
#document
| <svg svg>
|   <svg animateMotion>

#data
<svg><animateMotion attributeName="xlink:href"></svg>
#document
| <svg svg>
|   <svg animateMotion>


#data
<svg><animateTransform attributeName="href"></svg>
#document
| <svg svg>
|   <svg animateTransform>

#data
<svg><animateTransform attributeName="xlink:href"></svg>
#document
| <svg svg>
|   <svg animateTransform>


#data
<svg><set attributeName="href"></svg>
#document
| <svg svg>
|   <svg set>

#data
<svg><set attributeName="xlink:href"></svg>
#document
| <svg svg>
|   <svg set>
</script>

<script id="allowed" type="html5lib-testcases">
#data
<a nothref="javascript:alert(1)"></a>
#document
| <a>
|  nothref="javascript:alert(1)"

#data
<svg><a xlink:href="data:text/html,foobar"></a></svg>
#document
| <svg svg>
|  <svg a>
|    xlink href="data:text/html,foobar"

#data
<svg><set attributeName=" href "></svg>
#document
| <svg svg>
|   <svg set>
|     attributeName=" href "
</script>

<script>
for (const group of document.querySelectorAll("script[type='html5lib-testcases']")) {
  parse_html5lib_testcases(group.textContent).forEach((testcase, index) => {
    // Allow everything by default, we only care about the URLs being removed.
    let config = { sanitizer: {} };

    test((_) => {
      const div = document.createElement("div");
      div.setHTML(testcase.data, config);
      assert_testcase(div, testcase);
    }, `setHTML testcase ${group.id}/${index}, "${testcase.data}"`);

    test((_) => {
      assert_testcase(Document.parseHTML("<body>" + testcase.data, config).body, testcase);
    }, `parseHTML testcase ${group.id}/${index}, "${testcase.data}"`);
  });
}
</script>
</head>
<body>
</body>