From ba14ef8ecd5be4b801a1248c117130865511280b Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Fri, 16 Mar 2007 21:49:43 +0000 Subject: [PATCH] * (bug 8324) LinkSearch: search for https/ftp/irc/news weblinks Make LinkFilter and GlobalFunctions more flexible for other than http --- includes/GlobalFunctions.php | 6 ++++-- includes/LinkFilter.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c89bac3346..878a6d6998 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1935,8 +1935,9 @@ function wfRelativePath( $path, $from ) { function wfMakeUrlIndex( $url ) { wfSuppressWarnings(); $bits = parse_url( $url ); + $prots = array( 'http', 'https', 'ftp', 'irc', 'news' ); wfRestoreWarnings(); - if ( !$bits || $bits['scheme'] !== 'http' ) { + if ( !$bits || !in_array( $bits['scheme'], $prots ) ) { return false; } // Reverse the labels in the hostname, convert to lower case @@ -1946,7 +1947,8 @@ function wfMakeUrlIndex( $url ) { $reversedHost .= '.'; } // Reconstruct the pseudo-URL - $index = "http://$reversedHost"; + $prot = $bits['scheme']; + $index = "$prot://$reversedHost"; // Leave out user and password. Add the port, path, query and fragment if ( isset( $bits['port'] ) ) $index .= ':' . $bits['port']; if ( isset( $bits['path'] ) ) { diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index e03b59dd60..5010009501 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -47,8 +47,10 @@ class LinkFilter { * Asterisks in any other location are considered invalid. * * @static + * @param $filterEntry String: domainparts + * @param $prot String: protocol */ - function makeLike( $filterEntry ) { + function makeLike( $filterEntry , $prot = 'http' ) { if ( substr( $filterEntry, 0, 2 ) == '*.' ) { $subdomains = true; $filterEntry = substr( $filterEntry, 2 ); @@ -78,7 +80,7 @@ class LinkFilter { if ( substr( $host, -1, 1 ) !== '.' ) { $host .= '.'; } - $like = "http://$host"; + $like = "$prot://$host"; if ( $subdomains ) { $like .= '%'; -- 2.20.1