From: Amir E. Aharoni Date: Mon, 3 Sep 2012 08:28:08 +0000 (+0300) Subject: (bug 35167) Allow in toc items X-Git-Tag: 1.31.0-rc.0~22274 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=0ffe674912a937fb1527693733a6bc011a8a0c8d;p=lhc%2Fweb%2Fwiklou.git (bug 35167) Allow in toc items Added parser tests accordingly. Change-Id: Ia77f24f53e77b0b9d6112218c93ea15fdefac5de --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 59d379a06e..e778ca8a14 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4144,10 +4144,16 @@ class Parser { $safeHeadline = $this->mStripState->unstripBoth( $safeHeadline ); # Strip out HTML (first regex removes any tag not allowed) - # Allowed tags are and (bug 8393), (bug 26375) and (r105284) - # We strip any parameter from accepted tags (second regex) + # Allowed tags are: + # * and (bug 8393) + # * (bug 26375) + # * (r105284) + # * and (bug 35167) + # + # We strip any parameter from accepted tags (second regex), except dir="rtl|ltr" from , + # to allow setting directionality in toc items. $tocline = preg_replace( - array( '#<(?!/?(sup|sub|i|b)(?: [^>]*)?>).*?'.'>#', '#<(/?(sup|sub|i|b))(?: .*?)?'.'>#' ), + array( '#<(?!/?(span|sup|sub|i|b)(?: [^>]*)?>).*?'.'>#', '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|i|b))(?: .*?)?'.'>#' ), array( '', '<$1>' ), $safeHeadline ); diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 0c767c7ee1..fea9296e6b 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -10547,6 +10547,37 @@ __TOC__ !! end +!! test +span tags with directionality in TOC +!! input +__TOC__ +== C++ == + +== זבנג! == + +== The attributes on these span tags must be deleted from the TOC == + +== All attributes on these span tags must be deleted from the TOC == + +== Attributes after dir on these span tags must be deleted from the TOC == +!! result +

Contents

+ +
+

[edit] C++

+

[edit] זבנג!

+

[edit] The attributes on these span tags must be deleted from the TOC

+

[edit] All attributes on these span tags must be deleted from the TOC

+

[edit] Attributes after dir on these span tags must be deleted from the TOC

+ +!! end + !! article MediaWiki:Bug32057 !! text