summaryrefslogtreecommitdiff
path: root/extensions/SyntaxHighlight_GeSHi/tests/parserTests.txt
blob: c6aaa9a4f8bc56cec3a46e9462af61cb628b502a (plain)
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
!! hooks
source
!! endhooks

!! test
Non-existent language
!!input
<source lang="doesnotexist">
foobar
</source>
!! result
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>foobar</pre></div>

!! end

!! test
No language specified
!! wikitext
<source>
foo
</source>
!! html
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>foo</pre></div>

!! end

!! test
No language specified (no wellformed xml)
!! config
wgWellFormedXml=false
!! wikitext
<source>
bar
</source>
!! html
<div class="mw-highlight mw-content-ltr" dir=ltr><pre>bar</pre></div>

!! end

!! test
XSS is escaped
!!input
<source lang="doesnotexist">
<script>alert("pwnd")</script>
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>
<IMG
SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;
&#39;&#88;&#83;&#83;&#39;&#41;
\";alert('XSS');//
</script><script>alert('XSS');</script>
%253cscript%253ealert(document.cookie)%253c/script%253e
</source>
!! result
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>&lt;script>alert("pwnd")&lt;/script>
&lt;IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>
&lt;IMG
SRC=&amp;#106;&amp;#97;&amp;#118;&amp;#97;&amp;#115;&amp;#99;&amp;#114;&amp;#105;&amp;#112;&amp;#116;&amp;#58;&amp;#97;&amp;#108;&amp;#101;&amp;#114;&amp;#116;&amp;#40;
&amp;#39;&amp;#88;&amp;#83;&amp;#83;&amp;#39;&amp;#41;
\";alert('XSS');//
&lt;/script>&lt;script>alert('XSS');&lt;/script>
%253cscript%253ealert(document.cookie)%253c/script%253e</pre></div>

!! end

!! test
XSS is escaped (inline)
!!input
<source lang="doesnotexist" inline>
<script>alert("pwnd")</script>
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>
<IMG
SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;
&#39;&#88;&#83;&#83;&#39;&#41;
\";alert('XSS');//
</script><script>alert('XSS');</script>
%253cscript%253ealert(document.cookie)%253c/script%253e
</source>
!! result
<p><code class="mw-highlight" dir="ltr">&lt;script&gt;alert("pwnd")&lt;/script&gt; &lt;IMG SRC=`javascript:alert("RSnake says, 'XSS'")`&gt; &lt;IMG SRC=&amp;#106;&amp;#97;&amp;#118;&amp;#97;&amp;#115;&amp;#99;&amp;#114;&amp;#105;&amp;#112;&amp;#116;&amp;#58;&amp;#97;&amp;#108;&amp;#101;&amp;#114;&amp;#116;&amp;#40; &amp;#39;&amp;#88;&amp;#83;&amp;#83;&amp;#39;&amp;#41; \";alert('XSS');// &lt;/script&gt;&lt;script&gt;alert('XSS');&lt;/script&gt;&#160;%253cscript%253ealert(document.cookie)%253c/script%253e</code>
</p>
!! end

!! test
Default behaviour (inner is pre)
!!input
<source lang="javascript">
var a;
</source>
!! result
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span>
</pre></div>

!! end

!! test
Multiline <source/> in lists
!!input
* <source>a
b</source>

* foo <source>a
b</source>
!! html
<ul><li> <div class="mw-highlight mw-content-ltr" dir="ltr"><pre>a
b</pre></div></li></ul>
<ul><li> foo <div class="mw-highlight mw-content-ltr" dir="ltr"><pre>a
b</pre></div></li></ul>

!! html+tidy
<ul>
<li>
<div class="mw-highlight mw-content-ltr" dir="ltr">
<pre>
a
b
</pre></div>
</li>
</ul>
<ul>
<li>foo
<div class="mw-highlight mw-content-ltr" dir="ltr">
<pre>
a
b
</pre></div>
</li>
</ul>
!! end

!! test
Custom attributes
!!input
<source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;">var a;</source>
!! result
<div id="foo" class="bar mw-highlight mw-content-rtl" dir="rtl" style="font-size: larger;"><pre><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span>
</pre></div>

!! end

!! test
Inline attribute (inline code)
!!input
Text <source lang="javascript" inline>var a;</source>.
!! result
<p>Text <code class="mw-highlight" dir="ltr"><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span></code>.
</p>
!! end

!! test
Enclose none (inline code)
!!input
Text <source lang="javascript" enclose="none">var a;</source>.
!! result
<p>Text <code class="mw-highlight" dir="ltr"><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span></code>.
</p>
!! end