Add dotall modifier to EDITSECTION_REGEX
authorTim Starling <tstarling@wikimedia.org>
Tue, 18 Oct 2016 19:17:30 +0000 (12:17 -0700)
committerTim Starling <tstarling@wikimedia.org>
Tue, 18 Oct 2016 19:23:48 +0000 (12:23 -0700)
The regex failed to match for input text like

==<nowiki>
</nowiki>==

resulting in <mw:editsection> tags being leaked into the output.

Change-Id: I3daade920d2de8cd3fc31fcaabf46ffe14b047d5

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

index 9dfa97c..e9cdfcf 100644 (file)
@@ -213,7 +213,7 @@ class ParserOutput extends CacheTime {
        private $mMaxAdaptiveExpiry = INF;
 
        const EDITSECTION_REGEX =
-               '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
+               '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s';
 
        // finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL)
        // Current values imply that m=3933.333333 and b=-333.333333
index ba7b0d4..e12bc03 100644 (file)
@@ -513,6 +513,17 @@ Extra newlines between heading and content are swallowed
 </p>
 !! end
 
+!! test
+Heading with line break in nowiki
+!! wikitext
+== A <nowiki>B
+C</nowiki> ==
+!! html
+<h2><span class="mw-headline" id="A_B.0AC">A B
+C</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: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+
+!! end
+
 !! test
 Parsing an URL
 !! wikitext