X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fparser%2FParser.php;h=75c1faf7129e0d59a3fddd3110c2344656128108;hp=49f2ce1def6e13ab3e2dfe9b9af1e880c2d1f776;hb=3d560be428920fd4eb10ea6e9760dafbba8f9ddc;hpb=4795e19f8358d0f3ef2d345452fffa1f5780dc42 diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 49f2ce1def..75c1faf712 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2504,10 +2504,10 @@ class Parser { $value = '|'; break; case 'currentmonth': - $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'm' ) ); + $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'm' ), true ); break; case 'currentmonth1': - $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'n' ) ); + $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'n' ), true ); break; case 'currentmonthname': $value = $pageLang->getMonthName( MWTimestamp::getInstance( $ts )->format( 'n' ) ); @@ -2519,16 +2519,16 @@ class Parser { $value = $pageLang->getMonthAbbreviation( MWTimestamp::getInstance( $ts )->format( 'n' ) ); break; case 'currentday': - $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'j' ) ); + $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'j' ), true ); break; case 'currentday2': - $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'd' ) ); + $value = $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'd' ), true ); break; case 'localmonth': - $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'm' ) ); + $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'm' ), true ); break; case 'localmonth1': - $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'n' ) ); + $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'n' ), true ); break; case 'localmonthname': $value = $pageLang->getMonthName( MWTimestamp::getLocalInstance( $ts )->format( 'n' ) ); @@ -2540,10 +2540,10 @@ class Parser { $value = $pageLang->getMonthAbbreviation( MWTimestamp::getLocalInstance( $ts )->format( 'n' ) ); break; case 'localday': - $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'j' ) ); + $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'j' ), true ); break; case 'localday2': - $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'd' ) ); + $value = $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'd' ), true ); break; case 'pagename': $value = wfEscapeWikiText( $this->mTitle->getText() ); @@ -3108,10 +3108,29 @@ class Parser { throw $ex; } - # The interface for parser functions allows for extracting - # flags into the local scope. Extract any forwarded flags - # here. - extract( $result ); + // Extract any forwarded flags + if ( isset( $result['found'] ) ) { + $found = $result['found']; + } + if ( array_key_exists( 'text', $result ) ) { + // a string or null + $text = $result['text']; + } + if ( isset( $result['nowiki'] ) ) { + $nowiki = $result['nowiki']; + } + if ( isset( $result['isHTML'] ) ) { + $isHTML = $result['isHTML']; + } + if ( isset( $result['forceRawInterwiki'] ) ) { + $forceRawInterwiki = $result['forceRawInterwiki']; + } + if ( isset( $result['isChildObj'] ) ) { + $isChildObj = $result['isChildObj']; + } + if ( isset( $result['isLocalObj'] ) ) { + $isLocalObj = $result['isLocalObj']; + } } } @@ -3862,11 +3881,12 @@ class Parser { } if ( is_array( $output ) ) { - # Extract flags to local scope (to override $markerType) + // Extract flags $flags = $output; $output = $flags[0]; - unset( $flags[0] ); - extract( $flags ); + if ( isset( $flags['markerType'] ) ) { + $markerType = $flags['markerType']; + } } } else { if ( is_null( $attrText ) ) { @@ -4206,6 +4226,9 @@ class Parser { # Decode HTML entities $safeHeadline = Sanitizer::decodeCharReferences( $safeHeadline ); + + $safeHeadline = $this->normalizeSectionName( $safeHeadline ); + $fallbackHeadline = Sanitizer::escapeIdForAttribute( $safeHeadline, Sanitizer::ID_FALLBACK ); $linkAnchor = Sanitizer::escapeIdForLink( $safeHeadline ); $safeHeadline = Sanitizer::escapeIdForAttribute( $safeHeadline, Sanitizer::ID_PRIMARY ); @@ -5767,6 +5790,8 @@ class Parser { $text = $this->stripSectionName( $text ); $text = Sanitizer::normalizeSectionNameWhitespace( $text ); $text = Sanitizer::decodeCharReferences( $text ); + $text = $this->normalizeSectionName( $text ); + return '#' . Sanitizer::escapeIdForLink( $text ); } @@ -5786,6 +5811,7 @@ class Parser { $text = $this->stripSectionName( $text ); $text = Sanitizer::normalizeSectionNameWhitespace( $text ); $text = Sanitizer::decodeCharReferences( $text ); + $text = $this->normalizeSectionName( $text ); if ( isset( $wgFragmentMode[1] ) && $wgFragmentMode[1] === 'legacy' ) { // ForAttribute() and ForLink() are the same for legacy encoding @@ -5797,6 +5823,24 @@ class Parser { return "#$id"; } + /** + * Apply the same normalization as code making links to this section would + * + * @param string $text + * @return string + */ + private function normalizeSectionName( $text ) { + # T90902: ensure the same normalization is applied for IDs as to links + $titleParser = MediaWikiServices::getInstance()->getTitleParser(); + try { + + $parts = $titleParser->splitTitleString( "#$text" ); + } catch ( MalformedTitleException $ex ) { + return $text; + } + return $parts['fragment']; + } + /** * Strips a text string of wikitext for use in a section anchor *