From 8d4b762e24014ca96970b1ee348f0690858efc72 Mon Sep 17 00:00:00 2001 From: Elliott Eggleston Date: Mon, 16 Sep 2013 20:53:22 -0400 Subject: [PATCH] LinkSearch: use default protocol if unsupported 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/specials/SpecialLinkSearch.php b/includes/specials/SpecialLinkSearch.php index 5b0c56e598..ed6e2a4bbb 100644 --- a/includes/specials/SpecialLinkSearch.php +++ b/includes/specials/SpecialLinkSearch.php @@ -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( -- 2.20.1