Parser: Add <bdi> to the whitelist for TOC links
authorDerk-Jan Hartman <hartman.wiki@gmail.com>
Sun, 2 Nov 2014 17:19:56 +0000 (18:19 +0100)
committerDerk-Jan Hartman <hartman.wiki@gmail.com>
Sat, 27 Dec 2014 20:24:42 +0000 (21:24 +0100)
Bug: 72884
Change-Id: Id5aa9a4eb32fb185881141e55de700ae36f806c5

includes/parser/Parser.php
tests/parser/parserTests.txt

index e3a4ea5..6b2444e 100644 (file)
@@ -4636,14 +4636,15 @@ class Parser {
                        # * <sup> and <sub> (bug 8393)
                        # * <i> (bug 26375)
                        # * <b> (r105284)
+                       # * <bdi> (bug 72884)
                        # * <span dir="rtl"> and <span dir="ltr"> (bug 35167)
                        #
                        # We strip any parameter from accepted tags (second regex), except dir="rtl|ltr" from <span>,
                        # to allow setting directionality in toc items.
                        $tocline = preg_replace(
                                array(
-                                       '#<(?!/?(span|sup|sub|i|b)(?: [^>]*)?>).*?' . '>#',
-                                       '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|i|b))(?: .*?)?' . '>#'
+                                       '#<(?!/?(span|sup|sub|bdi|i|b)(?: [^>]*)?>).*?' . '>#',
+                                       '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|bdi|i|b))(?: .*?)?' . '>#'
                                ),
                                array( '', '<$1>' ),
                                $safeHeadline
index cf9d829..7eb152a 100644 (file)
@@ -19043,6 +19043,22 @@ __TOC__
 
 !! end
 
+!! test
+Bug 72884: bdi element in ToC
+!! wikitext
+__TOC__
+== <bdi>test</bdi> ==
+!! html
+<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
+<ul>
+<li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
+</ul>
+</div>
+
+<h2><span class="mw-headline" id="test"><bdi>test</bdi></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+
+!! end
+
 !! article
 MediaWiki:Bug32057
 !! text