From 0ffe674912a937fb1527693733a6bc011a8a0c8d Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Mon, 3 Sep 2012 11:28:08 +0300 Subject: [PATCH] (bug 35167) Allow in toc items Added parser tests accordingly. Change-Id: Ia77f24f53e77b0b9d6112218c93ea15fdefac5de --- includes/parser/Parser.php | 12 +++++++++--- tests/parser/parserTests.txt | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) 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 -- 2.20.1