Merge "Cleanup page creation in RevisionIntegrationTest"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 0d11d5a..f2e47dc 100644 (file)
@@ -2299,10 +2299,7 @@ class Parser {
                                        /**
                                         * Strip the whitespace interwiki links produce, see T10897
                                         */
-                                       $s = rtrim( $s . $prefix );
-                                       // Special case: strip newlines when only thing between
-                                       // this link and next are newlines
-                                       $s .= trim( $trail, "\n" ) === '' ? '' : $trail;
+                                       $s = rtrim( $s . $prefix ) . $trail; # T175416
                                        continue;
                                }
 
@@ -2330,10 +2327,7 @@ class Parser {
                                        /**
                                         * Strip the whitespace Category links produce, see T2087
                                         */
-                                       $s = rtrim( $s . $prefix ); # T2087, T87753
-                                       // Special case: strip newlines when only thing between
-                                       // this link and next are newlines
-                                       $s .= trim( $trail, "\n" ) === '' ? '' : $trail;
+                                       $s = rtrim( $s . $prefix ) . $trail; # T2087, T87753
 
                                        if ( $wasblank ) {
                                                $sortkey = $this->getDefaultSort();
@@ -2510,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' ) );
@@ -2525,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' ) );
@@ -2546,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() );
@@ -3237,6 +3231,8 @@ class Parser {
                                        . wfMessage( 'parser-template-loop-warning', $titleText )->inContentLanguage()->text()
                                        . '</span>';
                                $this->addTrackingCategory( 'template-loop-category' );
+                               $this->mOutput->addWarning( wfMessage( 'template-loop-warning',
+                                       wfEscapeWikiText( $titleText ) )->text() );
                                wfDebug( __METHOD__ . ": template loop broken at '$titleText'\n" );
                        }
                }
@@ -4208,6 +4204,8 @@ class Parser {
                        # Save headline for section edit hint before it's escaped
                        $headlineHint = $safeHeadline;
 
+                       # Decode HTML entities
+                       $safeHeadline = Sanitizer::decodeCharReferences( $safeHeadline );
                        $fallbackHeadline = Sanitizer::escapeIdForAttribute( $safeHeadline, Sanitizer::ID_FALLBACK );
                        $linkAnchor = Sanitizer::escapeIdForLink( $safeHeadline );
                        $safeHeadline = Sanitizer::escapeIdForAttribute( $safeHeadline, Sanitizer::ID_PRIMARY );
@@ -5768,6 +5766,7 @@ class Parser {
                # Strip out wikitext links(they break the anchor)
                $text = $this->stripSectionName( $text );
                $text = Sanitizer::normalizeSectionNameWhitespace( $text );
+               $text = Sanitizer::decodeCharReferences( $text );
                return '#' . Sanitizer::escapeIdForLink( $text );
        }
 
@@ -5786,6 +5785,7 @@ class Parser {
                # Strip out wikitext links(they break the anchor)
                $text = $this->stripSectionName( $text );
                $text = Sanitizer::normalizeSectionNameWhitespace( $text );
+               $text = Sanitizer::decodeCharReferences( $text );
 
                if ( isset( $wgFragmentMode[1] ) && $wgFragmentMode[1] === 'legacy' ) {
                        // ForAttribute() and ForLink() are the same for legacy encoding