Localisation updates from http://translatewiki.net.
[lhc/web/wiklou.git] / includes / Linker.php
index e5db232..05a9905 100644 (file)
@@ -1075,6 +1075,9 @@ class Linker {
        public static function userLink( $userId, $userName, $altUserName = false ) {
                if ( $userId == 0 ) {
                        $page = SpecialPage::getTitleFor( 'Contributions', $userName );
+                       if ( $altUserName === false ) {
+                               $altUserName = IP::prettifyIP( $userName );
+                       }
                } else {
                        $page = Title::makeTitle( NS_USER, $userName );
                }
@@ -1238,7 +1241,7 @@ class Linker {
        /**
         * This function is called by all recent changes variants, by the page history,
         * and by the user contributions list. It is responsible for formatting edit
-        * comments. It escapes any HTML in the comment, but adds some CSS to format
+        * summaries. It escapes any HTML in the summary, but adds some CSS to format
         * auto-generated comments (from section editing) and formats [[wikilinks]].
         *
         * @author Erik Moeller <moeller@scireview.de>
@@ -1275,6 +1278,7 @@ class Linker {
        static $autocommentLocal;
 
        /**
+        * Converts autogenerated comments in edit summaries into section links.
         * The pattern for autogen comments is / * foo * /, which makes for
         * some nasty regex.
         * We look for all comments, match any text before and after the comment,
@@ -1300,6 +1304,7 @@ class Linker {
        }
 
        /**
+        * Helper function for Linker::formatAutocomments
         * @param $match
         * @return string
         */
@@ -1373,7 +1378,18 @@ class Linker {
                self::$commentContextTitle = $title;
                self::$commentLocal = $local;
                $html = preg_replace_callback(
-                       '/\[\[:?(.*?)(\|(.*?))*\]\]([^[]*)/',
+                       '/
+                               \[\[
+                               :? # ignore optional leading colon
+                               ([^\]|]+) # 1. link target; page names cannot include ] or |
+                               (?:\|
+                                       # 2. a pipe-separated substring; only the last is captured
+                                       # Stop matching at | and ]] without relying on backtracking.
+                                       ((?:]?[^\]|])*+)
+                               )*
+                               \]\]
+                               ([^[]*) # 3. link trail (the text up until the next link)
+                       /x',
                        array( 'Linker', 'formatLinksInCommentCallback' ),
                        $comment );
                self::$commentContextTitle = null;
@@ -1399,8 +1415,8 @@ class Linker {
                }
 
                # Handle link renaming [[foo|text]] will show link as "text"
-               if ( $match[3] != "" ) {
-                       $text = $match[3];
+               if ( $match[2] != "" ) {
+                       $text = $match[2];
                } else {
                        $text = $match[1];
                }
@@ -1415,7 +1431,7 @@ class Linker {
                        }
                } else {
                        # Other kind of link
-                       if ( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) {
+                       if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) {
                                $trail = $submatch[1];
                        } else {
                                $trail = "";