Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -8976,6 +8976,99 @@ |
8977 | 8977 | |
8978 | 8978 | !! end |
8979 | 8979 | |
| 8980 | +!! test |
| 8981 | +Bug 33845: Headings become cursive in TOC when they contain an image |
| 8982 | +!! options |
| 8983 | +title=[[Main Page]] |
| 8984 | +!! input |
| 8985 | +__TOC__ |
| 8986 | +== Image [[Image:foobar.jpg]] == |
| 8987 | +!! result |
| 8988 | +<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> |
| 8989 | +<ul> |
| 8990 | +<li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li> |
| 8991 | +</ul> |
| 8992 | +</td></tr></table> |
| 8993 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Image">edit</a>]</span> <span class="mw-headline" id="Image"> Image <a href="https://www.mediawiki.org/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> </span></h2> |
| 8994 | + |
| 8995 | +!! end |
| 8996 | + |
| 8997 | +!! test |
| 8998 | +Bug 33845 (2): Headings become bold in TOC when they contain a blockquote |
| 8999 | +!! options |
| 9000 | +title=[[Main Page]] |
| 9001 | +!! input |
| 9002 | +__TOC__ |
| 9003 | +== <blockquote>Quote</blockquote> == |
| 9004 | +!! result |
| 9005 | +<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> |
| 9006 | +<ul> |
| 9007 | +<li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li> |
| 9008 | +</ul> |
| 9009 | +</td></tr></table> |
| 9010 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a>]</span> <span class="mw-headline" id="Quote"> <blockquote>Quote</blockquote> </span></h2> |
| 9011 | + |
| 9012 | +!! end |
| 9013 | + |
| 9014 | +!! test |
| 9015 | +Unclosed tags in TOC |
| 9016 | +!! options |
| 9017 | +title=[[Main Page]] |
| 9018 | +!! input |
| 9019 | +__TOC__ |
| 9020 | +== Proof: 2 < 3 == |
| 9021 | +<small>Hanc marginis exiguitas non caperet.</small> |
| 9022 | +QED |
| 9023 | +!! result |
| 9024 | +<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> |
| 9025 | +<ul> |
| 9026 | +<li class="toclevel-1 tocsection-1"><a href="#Proof:_2_.3C_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 < 3</span></a></li> |
| 9027 | +</ul> |
| 9028 | +</td></tr></table> |
| 9029 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Proof: 2 < 3">edit</a>]</span> <span class="mw-headline" id="Proof:_2_.3C_3"> Proof: 2 < 3 </span></h2> |
| 9030 | +<p><small>Hanc marginis exiguitas non caperet.</small> |
| 9031 | +QED |
| 9032 | +</p> |
| 9033 | +!! end |
| 9034 | + |
| 9035 | +!! test |
| 9036 | +Multiple tags in TOC |
| 9037 | +!! input |
| 9038 | +__TOC__ |
| 9039 | +== <i>Foo</i> <b>Bar</b> == |
| 9040 | + |
| 9041 | +== <i>Foo</i> <blockquote>Bar</blockquote> == |
| 9042 | +!! result |
| 9043 | +<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> |
| 9044 | +<ul> |
| 9045 | +<li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li> |
| 9046 | +<li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li> |
| 9047 | +</ul> |
| 9048 | +</td></tr></table> |
| 9049 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a>]</span> <span class="mw-headline" id="Foo_Bar"> <i>Foo</i> <b>Bar</b> </span></h2> |
| 9050 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a>]</span> <span class="mw-headline" id="Foo_Bar_2"> <i>Foo</i> <blockquote>Bar</blockquote> </span></h2> |
| 9051 | + |
| 9052 | +!! end |
| 9053 | + |
| 9054 | +!! test |
| 9055 | +Tags with parameters in TOC |
| 9056 | +!! input |
| 9057 | +__TOC__ |
| 9058 | +== <sup class="in-h2">Hello</sup> == |
| 9059 | + |
| 9060 | +== <sup class="a > b">Evilbye</sup> == |
| 9061 | +!! result |
| 9062 | +<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> |
| 9063 | +<ul> |
| 9064 | +<li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li> |
| 9065 | +<li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b">Evilbye</sup></span></a></li> |
| 9066 | +</ul> |
| 9067 | +</td></tr></table> |
| 9068 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Hello">edit</a>]</span> <span class="mw-headline" id="Hello"> <sup class="in-h2">Hello</sup> </span></h2> |
| 9069 | +<h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&action=edit&section=2" title="Edit section: b">Evilbye">edit</a>]</span> <span class="mw-headline" id="b.22.3EEvilbye"> <sup> b">Evilbye</sup> </span></h2> |
| 9070 | + |
| 9071 | +!! end |
| 9072 | + |
8980 | 9073 | !! article |
8981 | 9074 | MediaWiki:Bug32057 |
8982 | 9075 | !! text |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -4048,9 +4048,11 @@ |
4049 | 4049 | # link text with suffix |
4050 | 4050 | $safeHeadline = $this->replaceLinkHoldersText( $safeHeadline ); |
4051 | 4051 | |
4052 | | - # Strip out HTML (other than plain <sup> and <sub>: bug 8393, or <i>: bug 26375) |
| 4052 | + # Strip out HTML (first regex removes any tag not allowed) |
| 4053 | + # Allowed tags are <sup> and <sub> (bug 8393), <i> (bug 26375) and <b> (r105284) |
| 4054 | + # We strip any parameter from accepted tags (second regex) |
4053 | 4055 | $tocline = preg_replace( |
4054 | | - array( '#<(?!/?(sup|sub|i|b)).*?'.'>#', '#<(/?(sup|sub|i|b)).*?'.'>#' ), |
| 4056 | + array( '#<(?!/?(sup|sub|i|b)(?: [^>]*)?>).*?'.'>#', '#<(/?(sup|sub|i|b))(?: .*?)?'.'>#' ), |
4055 | 4057 | array( '', '<$1>' ), |
4056 | 4058 | $safeHeadline |
4057 | 4059 | ); |