LinkSearch: use default protocol if unsupported
authorElliott Eggleston <ejegg@ejegg.com>
Tue, 17 Sep 2013 00:53:22 +0000 (20:53 -0400)
committerBrian Wolff <bawolff+wn@gmail.com>
Sat, 16 Nov 2013 18:31:06 +0000 (18:31 +0000)
Default $protocol to http:// if part of link up to
colon or double-slash isn't in $wgUrlProtocols.

Also simplify elseif condition above - $protocol is
always blank there since neither if block above it
is executed.

Bug: 33029
Change-Id: I66d2c592998c750fe3da937b228fe1387fcd344c

includes/specials/SpecialLinkSearch.php

index 5b0c56e..ed6e2a4 100644 (file)
@@ -73,14 +73,17 @@ class LinkSearchPage extends QueryPage {
                        // For protocols without '//' like 'mailto:'
                        $protocol = substr( $target2, 0, $pr_cl + 1 );
                        $target2 = substr( $target2, $pr_cl + 1 );
-               } elseif ( $protocol == '' && $target2 != '' ) {
+               } elseif ( $target2 != '' ) {
                        // default
                        $protocol = 'http://';
                }
                if ( $protocol != '' && !in_array( $protocol, $protocols_list ) ) {
-                       // unsupported protocol, show original search request
+                       // Unsupported protocol, show original search request
                        $target2 = $target;
-                       $protocol = '';
+                       // Since links with unsupported protocols don't end up in
+                       // externallinks, assume $protocol is actually part of a link
+                       // containing ':' or '//' and default to http as above.
+                       $protocol = 'http://';
                }
 
                $out->addWikiMsg(