Escape unescaped messages shown on a diff page
[lhc/web/wiklou.git] / includes / Linker.php
index 0e9ef2b..ac4bb99 100644 (file)
@@ -209,8 +209,9 @@ class Linker {
                $dummy = new DummyLinker; // dummy linker instance for bc on the hooks
 
                $ret = null;
-               if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$html,
-               &$customAttribs, &$query, &$options, &$ret ) ) ) {
+               if ( !Hooks::run( 'LinkBegin',
+                       array( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) )
+               ) {
                        wfProfileOut( __METHOD__ );
                        return $ret;
                }
@@ -250,7 +251,7 @@ class Linker {
                }
 
                $ret = null;
-               if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
+               if ( Hooks::run( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
                        $ret = Html::rawElement( 'a', $attribs, $html );
                }
 
@@ -410,7 +411,7 @@ class Linker {
         */
        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
                $ret = "<strong class=\"selflink\">{$prefix}{$html}</strong>{$trail}";
-               if ( !wfRunHooks( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
+               if ( !Hooks::run( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
                        return $ret;
                }
 
@@ -496,7 +497,7 @@ class Linker {
                        $alt = self::fnamePart( $url );
                }
                $img = '';
-               $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
+               $success = Hooks::run( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
                if ( !$success ) {
                        wfDebug( "Hook LinkerMakeExternalImage changed the output of external image "
                                . "with url {$url} and alt text {$alt} to {$img}\n", true );
@@ -550,7 +551,7 @@ class Linker {
        ) {
                $res = null;
                $dummy = new DummyLinker;
-               if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
+               if ( !Hooks::run( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
                        &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
                        return $res;
                }
@@ -1030,7 +1031,7 @@ class Linker {
                        'title' => $alt
                );
 
-               if ( !wfRunHooks( 'LinkerMakeMediaLinkFile',
+               if ( !Hooks::run( 'LinkerMakeMediaLinkFile',
                        array( $title, $file, &$html, &$attribs, &$ret ) ) ) {
                        wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link "
                                . "with url {$url} and text {$html} to {$ret}\n", true );
@@ -1089,7 +1090,7 @@ class Linker {
                }
                $attribs['rel'] = Parser::getExternalLinkRel( $url, $title );
                $link = '';
-               $success = wfRunHooks( 'LinkerMakeExternalLink',
+               $success = Hooks::run( 'LinkerMakeExternalLink',
                        array( &$url, &$text, &$link, &$attribs, $linktype ) );
                if ( !$success ) {
                        wfDebug( "Hook LinkerMakeExternalLink changed the output of link "
@@ -1175,10 +1176,10 @@ class Linker {
                        $items[] = self::emailLink( $userId, $userText );
                }
 
-               wfRunHooks( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
+               Hooks::run( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
 
                if ( $items ) {
-                       return wfMessage( 'word-separator' )->plain()
+                       return wfMessage( 'word-separator' )->escaped()
                                . '<span class="mw-usertoollinks">'
                                . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
                                . '</span>';
@@ -1265,7 +1266,7 @@ class Linker {
                        $userId = $rev->getUser( Revision::FOR_THIS_USER );
                        $userText = $rev->getUserText( Revision::FOR_THIS_USER );
                        $link = self::userLink( $userId, $userText )
-                               . wfMessage( 'word-separator' )->plain()
+                               . wfMessage( 'word-separator' )->escaped()
                                . self::userToolLinks( $userId, $userText );
                } else {
                        $link = wfMessage( 'rev-deleted-user' )->escaped();
@@ -1332,7 +1333,7 @@ class Linker {
                                $auto = $match[2];
                                $post = $match[3];
                                $comment = null;
-                               wfRunHooks( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
+                               Hooks::run( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) );
                                if ( $comment === null ) {
                                        $link = '';
                                        if ( $title ) {
@@ -1490,9 +1491,12 @@ class Linker {
                # Foobar -- normal
                # :Foobar -- override special treatment of prefix (images, language links)
                # /Foobar -- convert to CurrentPage/Foobar
-               # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial / from text
+               # /Foobar/ -- convert to CurrentPage/Foobar, strip the initial and final / from text
                # ../ -- convert to CurrentPage, from CurrentPage/CurrentSubPage
-               # ../Foobar -- convert to CurrentPage/Foobar, from CurrentPage/CurrentSubPage
+               # ../Foobar -- convert to CurrentPage/Foobar,
+               #              (from CurrentPage/CurrentSubPage)
+               # ../Foobar/ -- convert to CurrentPage/Foobar, use 'Foobar' as text
+               #              (from CurrentPage/CurrentSubPage)
 
                wfProfileIn( __METHOD__ );
                $ret = $target; # default return value is no change
@@ -1538,7 +1542,7 @@ class Linker {
                                                $ret = implode( '/', array_slice( $exploded, 0, -$dotdotcount ) );
                                                # / at the end means don't show full path
                                                if ( substr( $nodotdot, -1, 1 ) === '/' ) {
-                                                       $nodotdot = substr( $nodotdot, 0, -1 );
+                                                       $nodotdot = rtrim( $nodotdot, '/' );
                                                        if ( $text === '' ) {
                                                                $text = $nodotdot . $suffix;
                                                        }
@@ -1808,7 +1812,7 @@ class Linker {
                $inner = self::buildRollbackLink( $rev, $context, $editCount );
 
                if ( !in_array( 'noBrackets', $options ) ) {
-                       $inner = $context->msg( 'brackets' )->rawParams( $inner )->plain();
+                       $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
                }
 
                return '<span class="mw-rollback-link">' . $inner . '</span>';
@@ -1893,7 +1897,7 @@ class Linker {
        ) {
                global $wgShowRollbackEditCount, $wgMiserMode;
 
-               // To config which pages are effected by miser mode
+               // To config which pages are affected by miser mode
                $disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
 
                if ( $context === null ) {