From d469f538474b5c860e3984a9c4b672faaa305b1f Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 2 Jul 2018 11:17:06 -0400 Subject: [PATCH] Parser: Remove style and script tags' content from TOC We don't want to display the stylesheet as part of the TOC entry if someone uses TemplateStyles in a heading. Bug: T198618 Change-Id: I2f7316daaba0cce662b6a4702ab87322e6783655 --- includes/parser/Parser.php | 7 +++++++ tests/parser/parserTests.txt | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index fd5ccb848b..12d899bc34 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4216,6 +4216,13 @@ class Parser { # Avoid insertion of weird stuff like by expanding the relevant sections $safeHeadline = $this->mStripState->unstripBoth( $safeHeadline ); + # Remove any (T10393) diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index e2da66282e..b1510029a1 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -24710,6 +24710,27 @@ __TOC__

test test test

!! end +!! test +T198618: style element in ToC +!! options +styletag=1 +!! wikitext +__TOC__ +==Style== +!! html/php +

Contents

+ +
+ +

Style[edit]

+ +!! html/parsoid + +

Style

+!! end + !! test Empty

tag in TOC, removed by Sanitizer (T92892) !! wikitext -- 2.20.1