| 1 |
!! options |
| 2 |
parsoid-compatible=wt2html,wt2wt |
| 3 |
version=2 |
| 4 |
!! end |
| 5 |
|
| 6 |
# Force the test runner to ensure the extension is loaded |
| 7 |
!! hooks |
| 8 |
source |
| 9 |
!! endhooks |
| 10 |
|
| 11 |
!! test |
| 12 |
Non-existent language |
| 13 |
!! wikitext |
| 14 |
<source lang="doesnotexist"> |
| 15 |
foobar |
| 16 |
</source> |
| 17 |
!! html/php |
| 18 |
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>foobar</pre></div> |
| 19 |
!! html/parsoid |
| 20 |
<div class="mw-highlight mw-content-ltr" dir="ltr" about="#mwt1" typeof="mw:Extension/source" data-mw='{"name":"source","attrs":{"lang":"doesnotexist"},"body":{"extsrc":"\nfoobar\n"}}'><pre>foobar</pre></div> |
| 21 |
!! end |
| 22 |
|
| 23 |
!! test |
| 24 |
No language specified |
| 25 |
!! options |
| 26 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 27 |
!! wikitext |
| 28 |
<source> |
| 29 |
foo |
| 30 |
</source> |
| 31 |
!! html |
| 32 |
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>foo</pre></div> |
| 33 |
!! end |
| 34 |
|
| 35 |
!! test |
| 36 |
No language specified (no wellformed xml) |
| 37 |
!! options |
| 38 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 39 |
!! config |
| 40 |
!! wikitext |
| 41 |
<source> |
| 42 |
bar |
| 43 |
</source> |
| 44 |
!! html |
| 45 |
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>bar</pre></div> |
| 46 |
!! end |
| 47 |
|
| 48 |
!! test |
| 49 |
XSS is escaped |
| 50 |
!! options |
| 51 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 52 |
!! wikitext |
| 53 |
<source lang="doesnotexist"> |
| 54 |
<script>alert("pwnd")</script> |
| 55 |
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> |
| 56 |
<IMG |
| 57 |
SRC=javascript:alert( |
| 58 |
'XSS') |
| 59 |
\";alert('XSS');// |
| 60 |
</script><script>alert('XSS');</script> |
| 61 |
%253cscript%253ealert(document.cookie)%253c/script%253e |
| 62 |
</source> |
| 63 |
!! html |
| 64 |
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre><script>alert("pwnd")</script> |
| 65 |
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> |
| 66 |
<IMG |
| 67 |
SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40; |
| 68 |
&#39;&#88;&#83;&#83;&#39;&#41; |
| 69 |
\";alert('XSS');// |
| 70 |
</script><script>alert('XSS');</script> |
| 71 |
%253cscript%253ealert(document.cookie)%253c/script%253e</pre></div> |
| 72 |
!! end |
| 73 |
|
| 74 |
!! test |
| 75 |
XSS is escaped (inline) |
| 76 |
!! options |
| 77 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 78 |
!! wikitext |
| 79 |
<source lang="doesnotexist" inline=""> |
| 80 |
<script>alert("pwnd")</script> |
| 81 |
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`> |
| 82 |
<IMG |
| 83 |
SRC=javascript:alert( |
| 84 |
'XSS') |
| 85 |
\";alert('XSS');// |
| 86 |
</script><script>alert('XSS');</script> |
| 87 |
%253cscript%253ealert(document.cookie)%253c/script%253e |
| 88 |
</source> |
| 89 |
!! html |
| 90 |
<p><code class="mw-highlight mw-content-ltr" dir="ltr"><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</code> |
| 91 |
</p> |
| 92 |
!! end |
| 93 |
|
| 94 |
!! test |
| 95 |
Default behaviour (inner is pre) |
| 96 |
!! options |
| 97 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 98 |
!! wikitext |
| 99 |
<source lang="javascript"> |
| 100 |
var a; |
| 101 |
</source> |
| 102 |
!! html |
| 103 |
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">a</span><span class="p">;</span> |
| 104 |
</pre></div> |
| 105 |
!! end |
| 106 |
|
| 107 |
!! test |
| 108 |
Multiline <source/> in lists |
| 109 |
!! options |
| 110 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 111 |
!! wikitext |
| 112 |
*<source>a |
| 113 |
b</source> |
| 114 |
|
| 115 |
*foo <source>a |
| 116 |
b</source> |
| 117 |
!! html |
| 118 |
<ul><li><div class="mw-highlight mw-content-ltr" dir="ltr"><pre>a |
| 119 |
b</pre></div></li></ul> |
| 120 |
<ul><li>foo <div class="mw-highlight mw-content-ltr" dir="ltr"><pre>a |
| 121 |
b</pre></div></li></ul> |
| 122 |
!! end |
| 123 |
|
| 124 |
!! test |
| 125 |
Custom attributes |
| 126 |
!! options |
| 127 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 128 |
!! wikitext |
| 129 |
<source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;">var a;</source> |
| 130 |
!! html |
| 131 |
<div id="foo" class="bar mw-highlight mw-highlight-lang-javascript mw-content-rtl" style="font-size: larger;" dir="rtl"><pre><span></span><span class="kd">var</span><span class="w"> </span><span class="nx">a</span><span class="p">;</span> |
| 132 |
</pre></div> |
| 133 |
!! end |
| 134 |
|
| 135 |
# The html/parsoid section verifies that Parsoid can handle attributes |
| 136 |
# that are not in key=value XML-like syntax. |
| 137 |
!! test |
| 138 |
Inline attribute (inline code) |
| 139 |
!! options |
| 140 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 141 |
!! wikitext |
| 142 |
Text <source lang="javascript" inline>var a;</source>. |
| 143 |
!! html/php |
| 144 |
<p>Text <code class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><span class="kd">var</span><span class="w"> </span><span class="nx">a</span><span class="p">;</span></code>. |
| 145 |
</p> |
| 146 |
!! html/parsoid |
| 147 |
<p>Text <code class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr" about="#mwt1" typeof="mw:Extension/source" data-mw='{"name":"source","attrs":{"lang":"javascript","inline":""},"body":{"extsrc":"var a;"}}'><span class="kd">var</span><span class="w"> </span><span class="nx">a</span><span class="p">;</span></code>.</p> |
| 148 |
!! end |
| 149 |
|
| 150 |
!! test |
| 151 |
Enclose none (inline code) |
| 152 |
!! options |
| 153 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 154 |
!! wikitext |
| 155 |
Text <source lang="javascript" enclose="none">var a;</source>. |
| 156 |
!! html |
| 157 |
<p>Text <code class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><span class="kd">var</span><span class="w"> </span><span class="nx">a</span><span class="p">;</span></code>. |
| 158 |
</p> |
| 159 |
!! end |
| 160 |
|
| 161 |
!! test |
| 162 |
Enclose with nowiki |
| 163 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 164 |
!! wikitext |
| 165 |
{{#tag:syntaxhighlight|<nowiki>foo</nowiki>|lang="text"|inline=none}} |
| 166 |
!! html/php |
| 167 |
<p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">foo</code> |
| 168 |
</p> |
| 169 |
!! html/parsoid |
| 170 |
<p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr" about="#mwt1" typeof="mw:Extension/syntaxhighlight mw:Transclusion" data-mw='{"name":"syntaxhighlight","attrs":{"lang":"text","inline":"none"},"body":{"extsrc":"foo"},"parts":[{"template":{"target":{"wt":"#tag:syntaxhighlight","function":"tag"},"params":{"1":{"wt":"<nowiki>foo</nowiki>"},"lang":{"wt":"\"text\""},"inline":{"wt":"none"}},"i":0}}]}'>foo</code></p> |
| 171 |
!! end |
| 172 |
|
| 173 |
!! test |
| 174 |
Self-closing tag |
| 175 |
!! options |
| 176 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 177 |
!! wikitext |
| 178 |
<syntaxhighlight lang="CSharp" /> |
| 179 |
!! html |
| 180 |
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"></div> |
| 181 |
!! end |
| 182 |
|
| 183 |
!! test |
| 184 |
No code |
| 185 |
!! options |
| 186 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 187 |
!! wikitext |
| 188 |
<source lang="CSharp"></source> |
| 189 |
!! html |
| 190 |
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"></div> |
| 191 |
!! end |
| 192 |
|
| 193 |
!! test |
| 194 |
Just whitespace |
| 195 |
!! options |
| 196 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 197 |
!! wikitext |
| 198 |
<source lang="CSharp"> </source> |
| 199 |
!! html |
| 200 |
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"></div> |
| 201 |
!! end |
| 202 |
|
| 203 |
!! test |
| 204 |
tabs plus tidy (T32930, T59826) |
| 205 |
!! options |
| 206 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 207 |
!! wikitext |
| 208 |
<syntaxhighlight lang="javascript" enclose="pre" highlight="2-3"> |
| 209 |
function doSomething() { |
| 210 |
var foo, |
| 211 |
bar; |
| 212 |
if (baz) { |
| 213 |
</syntaxhighlight> |
| 214 |
!! html |
| 215 |
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">function</span><span class="w"> </span><span class="nx">doSomething</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> |
| 216 |
<span class="hll"><span class="w"> </span><span class="kd">var</span><span class="w"> </span><span class="nx">foo</span><span class="p">,</span> |
| 217 |
</span><span class="hll"><span class="w"> </span><span class="nx">bar</span><span class="p">;</span> |
| 218 |
</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="nx">baz</span><span class="p">)</span><span class="w"> </span><span class="p">{</span> |
| 219 |
</pre></div> |
| 220 |
!! end |
| 221 |
|
| 222 |
!! test |
| 223 |
deprecated source tag adds tracking category |
| 224 |
!! options |
| 225 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 226 |
!! options |
| 227 |
cat |
| 228 |
nohtml |
| 229 |
!! wikitext |
| 230 |
<source lang="python">print('Hi')</source> |
| 231 |
!! html/php |
| 232 |
cat=Pages_using_deprecated_source_tags sort= |
| 233 |
!! end |
| 234 |
|
| 235 |
!! test |
| 236 |
deprecated enclose option adds tracking category |
| 237 |
!! options |
| 238 |
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } |
| 239 |
cat |
| 240 |
nohtml |
| 241 |
!! wikitext |
| 242 |
<syntaxhighlight enclose="none" lang="python">print('Hi')</syntaxhighlight> |
| 243 |
!! html/php |
| 244 |
cat=Pages_using_deprecated_enclose_attributes sort= |
| 245 |
!! end |