* (bug 8324) LinkSearch: search for https/ftp/irc/news weblinks
authorRaimond Spekking <raymond@users.mediawiki.org>
Fri, 16 Mar 2007 21:49:43 +0000 (21:49 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Fri, 16 Mar 2007 21:49:43 +0000 (21:49 +0000)
Make LinkFilter and GlobalFunctions more flexible for other than http

includes/GlobalFunctions.php
includes/LinkFilter.php

index c89bac3..878a6d6 100644 (file)
@@ -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'] ) ) {
index e03b59d..5010009 100644 (file)
@@ -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 .= '%';