mediawiki-extensions-Syntax.../tests/parserTests.txt
Timo Tijhof e033d2db9e Add parser tests for block and inline behaviour
Change-Id: I0af26e8b86f2f9060bd88db6d36449d983978f09
2015-06-25 05:46:42 +01:00

70 lines
1.8 KiB
Plaintext

!! hooks
source
!! endhooks
!! test
Non-existent language
!!input
<source lang="doesnotexist">
foobar
</source>
!! result
<div class="mw-highlight"><pre>foobar</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"><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
Default behaviour (inner is pre)
!!input
<source lang="javascript">
var a;
</source>
!! result
<div class="mw-highlight"><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"><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"><span class="kd">var</span> <span class="nx">a</span><span class="p">;</span></code>.
</p>
!! end