mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-30 17:14:55 +00:00
2d3af74c39
We already add the dir=ltr/rtl HTML attribute so this should be a no-op and makes it consistent with block snippets. Change-Id: I53e9204cc3bd54ba167f6f91e718a9d35b5bdfd0
199 lines
5.9 KiB
Plaintext
199 lines
5.9 KiB
Plaintext
!! Version 2
|
|
# Force the test runner to ensure the extension is loaded
|
|
!! hooks
|
|
source
|
|
!! endhooks
|
|
|
|
!! test
|
|
Non-existent language
|
|
!! wikitext
|
|
<source lang="doesnotexist">
|
|
foobar
|
|
</source>
|
|
!! html
|
|
<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
|
|
!! wikitext
|
|
<source>
|
|
bar
|
|
</source>
|
|
!! html
|
|
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre>bar</pre></div>
|
|
!! end
|
|
|
|
!! test
|
|
XSS is escaped
|
|
!! wikitext
|
|
<source lang="doesnotexist">
|
|
<script>alert("pwnd")</script>
|
|
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>
|
|
<IMG
|
|
SRC=javascript:alert(
|
|
'XSS')
|
|
\";alert('XSS');//
|
|
</script><script>alert('XSS');</script>
|
|
%253cscript%253ealert(document.cookie)%253c/script%253e
|
|
</source>
|
|
!! html
|
|
<div class="mw-highlight mw-content-ltr" dir="ltr"><pre><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</pre></div>
|
|
!! end
|
|
|
|
!! test
|
|
XSS is escaped (inline)
|
|
!! wikitext
|
|
<source lang="doesnotexist" inline>
|
|
<script>alert("pwnd")</script>
|
|
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>
|
|
<IMG
|
|
SRC=javascript:alert(
|
|
'XSS')
|
|
\";alert('XSS');//
|
|
</script><script>alert('XSS');</script>
|
|
%253cscript%253ealert(document.cookie)%253c/script%253e
|
|
</source>
|
|
!! html
|
|
<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>
|
|
</p>
|
|
!! end
|
|
|
|
!! test
|
|
Default behaviour (inner is pre)
|
|
!! wikitext
|
|
<source lang="javascript">
|
|
var a;
|
|
</source>
|
|
!! html
|
|
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span>
|
|
</pre></div>
|
|
!! end
|
|
|
|
!! test
|
|
Multiline <source/> in lists
|
|
!! wikitext
|
|
* <source>a
|
|
b</source>
|
|
|
|
* foo <source>a
|
|
b</source>
|
|
!! html+untidy
|
|
<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
|
|
!! wikitext
|
|
<source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;">var a;</source>
|
|
!! html
|
|
<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="nx">a</span><span class="p">;</span>
|
|
</pre></div>
|
|
!! end
|
|
|
|
!! test
|
|
Inline attribute (inline code)
|
|
!! wikitext
|
|
Text <source lang="javascript" inline>var a;</source>.
|
|
!! html
|
|
<p>Text <code class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span></code>.
|
|
</p>
|
|
!! end
|
|
|
|
!! test
|
|
Enclose none (inline code)
|
|
!! wikitext
|
|
Text <source lang="javascript" enclose="none">var a;</source>.
|
|
!! html
|
|
<p>Text <code class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span></code>.
|
|
</p>
|
|
!! end
|
|
|
|
!! test
|
|
Enclose with nowiki
|
|
!! wikitext
|
|
{{#tag:syntaxhighlight|<nowiki>foo</nowiki>|lang="text"|inline=none}}
|
|
!! html
|
|
<p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" dir="ltr">foo</code>
|
|
</p>
|
|
!! end
|
|
|
|
!! test
|
|
No code
|
|
!! wikitext
|
|
<source lang="CSharp"></source>
|
|
!! html
|
|
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"></div>
|
|
!! end
|
|
|
|
!! test
|
|
Just whitespace
|
|
!! wikitext
|
|
<source lang="CSharp"> </source>
|
|
!! html
|
|
<div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"></div>
|
|
!! end
|
|
|
|
!! test
|
|
tabs plus tidy (T32930, T59826)
|
|
!! wikitext
|
|
<syntaxhighlight lang="javascript" enclose="pre" highlight="2-3">
|
|
function doSomething() {
|
|
var foo,
|
|
bar;
|
|
if (baz) {
|
|
</syntaxhighlight>
|
|
!! html+tidy
|
|
<div class="mw-highlight mw-highlight-lang-javascript mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">function</span> <span class="nx">doSomething</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="hll"> <span class="kd">var</span> <span class="nx">foo</span><span class="p">,</span>
|
|
</span><span class="hll"> <span class="nx">bar</span><span class="p">;</span>
|
|
</span> <span class="k">if</span> <span class="p">(</span><span class="nx">baz</span><span class="p">)</span> <span class="p">{</span>
|
|
</pre></div>
|
|
!! end
|
|
|
|
!! test
|
|
deprecated source tag adds tracking category
|
|
!! options
|
|
cat
|
|
!! wikitext
|
|
<source lang="python">print('Hi')</source>
|
|
!! html+tidy
|
|
cat=Pages_using_deprecated_source_tags sort=
|
|
!! end
|
|
|
|
!! test
|
|
deprecated enclose option adds tracking category
|
|
!! options
|
|
cat
|
|
!! wikitext
|
|
<syntaxhighlight enclose="none" lang="python">print('Hi')</syntaxhighlight>
|
|
!! html+tidy
|
|
cat=Pages_using_deprecated_enclose_attributes sort=
|
|
!! end
|