Merge "Go search to consider fragment only title invalid"
[lhc/web/wiklou.git] / includes / Linker.php
index 56e377d..da8daf4 100644 (file)
@@ -205,7 +205,8 @@ class Linker {
         */
        public static function normaliseSpecialPage( LinkTarget $target ) {
                if ( $target->getNamespace() == NS_SPECIAL && !$target->isExternal() ) {
-                       list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $target->getDBkey() );
+                       list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+                               resolveAlias( $target->getDBkey() );
                        if ( !$name ) {
                                return $target;
                        }
@@ -430,7 +431,11 @@ class Linker {
                        $s = $thumb->toHtml( $params );
                }
                if ( $frameParams['align'] != '' ) {
-                       $s = "<div class=\"float{$frameParams['align']}\">{$s}</div>";
+                       $s = Html::rawElement(
+                               'div',
+                               [ 'class' => 'float' . $frameParams['align'] ],
+                               $s
+                       );
                }
                return str_replace( "\n", ' ', $prefix . $s . $postfix );
        }
@@ -1071,10 +1076,6 @@ class Linker {
         * @author Erik Moeller <moeller@scireview.de>
         * @since 1.16.3. $wikiId added in 1.26
         *
-        * Note: there's not always a title to pass to this function.
-        * Since you can't set a default parameter for a reference, I've turned it
-        * temporarily to a value pass. Should be adjusted further. --brion
-        *
         * @param string $comment
         * @param Title|null $title Title object (to generate link to the section in autocomment)
         *  or null
@@ -1207,7 +1208,8 @@ class Linker {
         * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
         *  as used by WikiMap.
         *
-        * @return string
+        * @return string HTML
+        * @return-taint onlysafefor_html
         */
        public static function formatLinksInComment(
                $comment, $title = null, $local = false, $wikiId = null
@@ -1215,6 +1217,7 @@ class Linker {
                return preg_replace_callback(
                        '/
                                \[\[
+                               \s*+ # ignore leading whitespace, the *+ quantifier disallows backtracking
                                :? # ignore optional leading colon
                                ([^\]|]+) # 1. link target; page names cannot include ] or |
                                (?:\|