SECURITY: rate-limit and prevent blocked users from changing email
[lhc/web/wiklou.git] / includes / Linker.php
index 3f50c97..ae50c66 100644 (file)
@@ -894,7 +894,7 @@ class Linker {
         * @since 1.16.3. $altUserName was added in 1.19.
         */
        public static function userLink( $userId, $userName, $altUserName = false ) {
-               if ( $userName === '' ) {
+               if ( $userName === '' || $userName === false || $userName === null ) {
                        wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
                                'that need to be fixed?' );
                        return wfMessage( 'empty-username' )->parse();
@@ -1237,18 +1237,17 @@ class Linker {
                                                // that starts with "#". Before PHP 7 (and still on HHVM) substr() would
                                                // return false if the start offset is the end of the string.
                                                // On PHP 7+, it gracefully returns empty string instead.
-                                               if ( $section === false ) {
-                                                       $section = '';
-                                               }
-                                               if ( $local ) {
-                                                       $sectionTitle = new TitleValue( NS_MAIN, '', $section );
-                                               } else {
-                                                       $sectionTitle = $title->createFragmentTarget( $section );
-                                               }
-                                               if ( $sectionTitle ) {
+                                               if ( $section !== '' && $section !== false ) {
+                                                       if ( $local ) {
+                                                               $sectionTitle = new TitleValue( NS_MAIN, '', $section );
+                                                       } else {
+                                                               $sectionTitle = $title->createFragmentTarget( $section );
+                                                       }
                                                        $auto = Linker::makeCommentLink(
-                                                               $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
-                                                               $wikiId, 'noclasses'
+                                                               $sectionTitle,
+                                                               $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
+                                                               $wikiId,
+                                                               'noclasses'
                                                        );
                                                }
                                        }