X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2Fparser%2FParser.php;h=e54588750b2c2fe36d9fa34e251289b3a357502b;hb=87f40138c64ddccb6dc6d54531cea02af40ef0f3;hp=b2d8511de867992199510fa3ff13584873b779d8;hpb=92571d7c1a9c25604382f9c395e487e44cc442d5;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index b2d8511de8..e54588750b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -358,7 +358,7 @@ class Parser { $this->mLangLinkLanguages = []; $this->currentRevisionCache = null; - $this->mStripState = new StripState; + $this->mStripState = new StripState( $this ); # Clear these on every parse, T6549 $this->mTplRedirCache = $this->mTplDomCache = []; @@ -543,6 +543,11 @@ class Parser { $this->mOutput->setLimitReportData( 'limitreport-expensivefunctioncount', [ $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit() ] ); + + foreach ( $this->mStripState->getLimitReport() as list( $key, $value ) ) { + $this->mOutput->setLimitReportData( $key, $value ); + } + Hooks::run( 'ParserLimitReportPrepare', [ $this, $this->mOutput ] ); $limitReport = "NewPP limit report\n"; @@ -1108,7 +1113,11 @@ class Parser { $line = "{$line}"; } array_pop( $tr_attributes ); - $outLine = $line . str_repeat( '', $indent_level ); + if ( $indent_level > 0 ) { + $outLine = rtrim( $line ) . str_repeat( '', $indent_level ); + } else { + $outLine = $line; + } } elseif ( $first_two === '|-' ) { # Now we have a table row $line = preg_replace( '#^\|-+#', '', $line ); @@ -1199,13 +1208,15 @@ class Parser { # be mistaken as delimiting cell parameters # Bug T153140: Neither should language converter markup. if ( preg_match( '/\[\[|-\{/', $cell_data[0] ) === 1 ) { - $cell = "{$previous}<{$last_tag}>{$cell}"; + $cell = "{$previous}<{$last_tag}>" . trim( $cell ); } elseif ( count( $cell_data ) == 1 ) { - $cell = "{$previous}<{$last_tag}>{$cell_data[0]}"; + // Whitespace in cells is trimmed + $cell = "{$previous}<{$last_tag}>" . trim( $cell_data[0] ); } else { $attributes = $this->mStripState->unstripBoth( $cell_data[0] ); $attributes = Sanitizer::fixTagAttributes( $attributes, $last_tag ); - $cell = "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}"; + // Whitespace in cells is trimmed + $cell = "{$previous}<{$last_tag}{$attributes}>" . trim( $cell_data[1] ); } $outLine .= $cell; @@ -1863,8 +1874,8 @@ class Parser { $dtrail = ''; - # Set linktype for CSS - if URL==text, link is essentially free - $linktype = ( $text === $url ) ? 'free' : 'text'; + # Set linktype for CSS + $linktype = 'text'; # No link text, e.g. [http://domain.tld/some.link] if ( $text == '' ) { @@ -2215,8 +2226,14 @@ class Parser { $link = $origLink; } - $unstrip = $this->mStripState->unstripNoWiki( $link ); - $nt = is_string( $unstrip ) ? Title::newFromText( $unstrip ) : null; + // \x7f isn't a default legal title char, so most likely strip + // markers will force us into the "invalid form" path above. But, + // just in case, let's assert that xmlish tags aren't valid in + // the title position. + $unstrip = $this->mStripState->killMarkers( $link ); + $noMarkers = ( $unstrip === $link ); + + $nt = $noMarkers ? Title::newFromText( $link ) : null; if ( $nt === null ) { $s .= $prefix . '[[' . $line; continue; @@ -4032,17 +4049,14 @@ class Parser { # Inhibit editsection links if requested in the page if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) { - $maybeShowEditLink = $showEditLink = false; + $maybeShowEditLink = false; } else { - $maybeShowEditLink = true; /* Actual presence will depend on ParserOptions option */ - $showEditLink = $this->mOptions->getEditSection(); - } - if ( $showEditLink ) { - $this->mOutput->setEditSectionTokens( true ); + $maybeShowEditLink = true; /* Actual presence will depend on post-cache transforms */ } # Get all headlines for numbering them and adding funky stuff like [edit] # links - this is for later, but we need the number of headlines right now + # This regexp also trims whitespace in the heading's content $matches = []; $numMatches = preg_match_all( '/[1-6])(?P.*?>)\s*(?P
[\s\S]*?)\s*<\/H[1-6] *>/i', @@ -4390,9 +4404,9 @@ class Parser { * $this : caller * $section : the section number * &$sectionContent : ref to the content of the section - * $showEditLinks : boolean describing whether this section has an edit link + * $maybeShowEditLinks : boolean describing whether this section has an edit link */ - Hooks::run( 'ParserSectionCreate', [ $this, $i, &$sections[$i], $showEditLink ] ); + Hooks::run( 'ParserSectionCreate', [ $this, $i, &$sections[$i], $maybeShowEditLink ] ); $i++; } @@ -5991,11 +6005,13 @@ class Parser { * unserializeHalfParsedText(). The text can then be safely incorporated into * the return value of a parser hook. * + * @deprecated since 1.31 * @param string $text * * @return array */ public function serializeHalfParsedText( $text ) { + wfDeprecated( __METHOD__, '1.31' ); $data = [ 'text' => $text, 'version' => self::HALF_PARSED_VERSION, @@ -6016,11 +6032,13 @@ class Parser { * If the $data array has been stored persistently, the caller should first * check whether it is still valid, by calling isValidHalfParsedText(). * + * @deprecated since 1.31 * @param array $data Serialized data * @throws MWException * @return string */ public function unserializeHalfParsedText( $data ) { + wfDeprecated( __METHOD__, '1.31' ); if ( !isset( $data['version'] ) || $data['version'] != self::HALF_PARSED_VERSION ) { throw new MWException( __METHOD__ . ': invalid version' ); } @@ -6041,11 +6059,13 @@ class Parser { * serializeHalfParsedText(), is compatible with the current version of the * parser. * + * @deprecated since 1.31 * @param array $data * * @return bool */ public function isValidHalfParsedText( $data ) { + wfDeprecated( __METHOD__, '1.31' ); return isset( $data['version'] ) && $data['version'] == self::HALF_PARSED_VERSION; }