Disable $wgServer autodetection to prevent cache poisoning attacks
[lhc/web/wiklou.git] / includes / Linker.php
index a79ec3a..864019d 100644 (file)
@@ -21,7 +21,7 @@
  */
 use MediaWiki\Linker\LinkTarget;
 use MediaWiki\MediaWikiServices;
-use MediaWiki\Storage\RevisionRecord;
+use MediaWiki\Revision\RevisionRecord;
 
 /**
  * Some internal bits split of from Skin.php. These functions are used
@@ -688,35 +688,38 @@ class Linker {
                if ( $label == '' ) {
                        $label = $title->getPrefixedText();
                }
-               $encLabel = htmlspecialchars( $label );
+               $repoGroup = MediaWikiServices::getInstance()->getRepoGroup();
                $currentExists = $time
-                       && MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title ) !== false;
+                       && $repoGroup->findFile( $title ) !== false;
 
                if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
                        && !$currentExists
                ) {
-                       $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
-
-                       if ( $redir ) {
-                               // We already know it's a redirect, so mark it
-                               // accordingly
+                       if ( $repoGroup->getLocalRepo()->checkRedirect( $title ) ) {
+                               // We already know it's a redirect, so mark it accordingly
                                return self::link(
                                        $title,
-                                       $encLabel,
+                                       htmlspecialchars( $label ),
                                        [ 'class' => 'mw-redirect' ],
                                        wfCgiToArray( $query ),
                                        [ 'known', 'noclasses' ]
                                );
                        }
 
-                       $href = self::getUploadUrl( $title, $query );
-
-                       return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
-                               htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
-                               $encLabel . '</a>';
+                       return Html::element( 'a', [
+                                       'href' => self::getUploadUrl( $title, $query ),
+                                       'class' => 'new',
+                                       'title' => $title->getPrefixedText()
+                               ], $label );
                }
 
-               return self::link( $title, $encLabel, [], wfCgiToArray( $query ), [ 'known', 'noclasses' ] );
+               return self::link(
+                       $title,
+                       htmlspecialchars( $label ),
+                       [],
+                       wfCgiToArray( $query ),
+                       [ 'known', 'noclasses' ]
+               );
        }
 
        /**
@@ -888,7 +891,7 @@ class Linker {
         * Make user link (or user contributions for unregistered users)
         * @param int $userId User id in database.
         * @param string $userName User name in database.
-        * @param string $altUserName Text to display instead of the user name (optional)
+        * @param string|false $altUserName Text to display instead of the user name (optional)
         * @return string HTML fragment
         * @since 1.16.3. $altUserName was added in 1.19.
         */
@@ -1038,7 +1041,7 @@ class Linker {
                }
 
                $userTalkPage = new TitleValue( NS_USER_TALK, strtr( $userText, ' ', '_' ) );
-               $moreLinkAttribs['class'] = 'mw-usertoollinks-talk';
+               $moreLinkAttribs = [ 'class' => 'mw-usertoollinks-talk' ];
 
                return self::link( $userTalkPage,
                        wfMessage( 'talkpagelinktext' )->escaped(),
@@ -1060,7 +1063,7 @@ class Linker {
                }
 
                $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
-               $moreLinkAttribs['class'] = 'mw-usertoollinks-block';
+               $moreLinkAttribs = [ 'class' => 'mw-usertoollinks-block' ];
 
                return self::link( $blockPage,
                        wfMessage( 'blocklink' )->escaped(),
@@ -1081,7 +1084,7 @@ class Linker {
                }
 
                $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
-               $moreLinkAttribs['class'] = 'mw-usertoollinks-mail';
+               $moreLinkAttribs = [ 'class' => 'mw-usertoollinks-mail' ];
                return self::link( $emailPage,
                        wfMessage( 'emaillink' )->escaped(),
                        $moreLinkAttribs
@@ -1909,7 +1912,7 @@ class Linker {
         * @since 1.16.3. $context added in 1.20. $editCount added in 1.21
         * @param Revision $rev
         * @param IContextSource|null $context Context to use or null for the main context.
-        * @param int $editCount Number of edits that would be reverted
+        * @param int|false $editCount Number of edits that would be reverted
         * @return string HTML fragment
         */
        public static function buildRollbackLink( $rev, IContextSource $context = null,