Sanitize $limitReport before outputting
authorcsteipp <csteipp@wikimedia.org>
Mon, 15 Apr 2013 20:42:02 +0000 (13:42 -0700)
committercsteipp <csteipp@wikimedia.org>
Mon, 15 Apr 2013 20:48:15 +0000 (13:48 -0700)
Prevents possible injection of "-->" and other HTML by extensions using
the ParserLimitReport hook.

bug: 46084
Change-Id: Id97b6668da6df3e5e4c0acefffa00c82cac3c44a

includes/parser/Parser.php

index 0247d3e..3ada925 100644 (file)
@@ -501,6 +501,11 @@ class Parser {
                                "Highest expansion depth: {$this->mHighestExpansionDepth}/{$this->mOptions->getMaxPPExpandDepth()}\n" .
                                $PFreport;
                        wfRunHooks( 'ParserLimitReport', array( $this, &$limitReport ) );
+
+                       // Sanitize for comment. Note '‐' in the replacement is U+2010,
+                       // which looks much like the problematic '-'.
+                       $limitReport = str_replace( array( '-', '&' ), array( '‐', '&amp;' ), $limitReport );
+
                        $text .= "\n<!-- \n$limitReport-->\n";
 
                        if ( $this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10 ) {