* (bug 5546) Watchlist reflects logged actions like move, protection, undelete
* (bug 9019) No warning during upload if image description page exists, but no
image
+* Support protocols other than HTTP in LinkFilter, use $wgUrlProtocols
* (bug 8582) Allow thumbnailing when imagesize has a space.
* (bug 8716) Change math_inputhash and math_outputhash to byte for Postgres
* (bug 8558) Correct display of timestamps on some pages when using Postgres
-Support protocols other than HTTP in LinkFilter
-
== Languages updated ==
* Arabic (ar)
* Make a URL index, appropriate for the el_index field of externallinks.
*/
function wfMakeUrlIndex( $url ) {
- wfSuppressWarnings();
+ global $wgUrlProtocols; // Allow all protocols defined in DefaultSettings/LocalSettings.php
$bits = parse_url( $url );
- $prots = array( 'http', 'https', 'ftp', 'irc', 'news' );
+ wfSuppressWarnings();
wfRestoreWarnings();
- if ( !$bits || !in_array( $bits['scheme'], $prots ) ) {
+ if ( !$bits ) {
return false;
}
+ // most of the protocols are followed by ://, but mailto: and sometimes news: not, check for it
+ $delimiter = '';
+ if ( in_array( $bits['scheme'] . '://' , $wgUrlProtocols ) ) {
+ $delimiter = '://';
+ } elseif ( in_array( $bits['scheme'] .':' , $wgUrlProtocols ) ) {
+ $delimiter = ':';
+ // parse_url detects for news: and mailto: the host part of an url as path
+ // We have to correct this wrong detection
+ if ( isset ( $bits['path'] ) ) {
+ $bits['host'] = $bits['path'];
+ $bits['path'] = '';
+ }
+ } else {
+ return false;
+ }
+
// Reverse the labels in the hostname, convert to lower case
- $reversedHost = strtolower( implode( '.', array_reverse( explode( '.', $bits['host'] ) ) ) );
+ // For emails reverse domainpart only
+ if ( $bits['scheme'] == 'mailto' ) {
+ $mailparts = explode( '@', $bits['host'] );
+ $domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) );
+ $reversedHost = $domainpart . '@' . $mailparts[0];
+ } else {
+ $reversedHost = strtolower( implode( '.', array_reverse( explode( '.', $bits['host'] ) ) ) );
+ }
// Add an extra dot to the end
if ( substr( $reversedHost, -1, 1 ) !== '.' ) {
$reversedHost .= '.';
}
// Reconstruct the pseudo-URL
$prot = $bits['scheme'];
- $index = "$prot://$reversedHost";
+ $index = "$prot$delimiter$reversedHost";
// Leave out user and password. Add the port, path, query and fragment
if ( isset( $bits['port'] ) ) $index .= ':' . $bits['port'];
if ( isset( $bits['path'] ) ) {
* @param $filterEntry String: domainparts
* @param $prot String: protocol
*/
- function makeLike( $filterEntry , $prot = 'http' ) {
+ function makeLike( $filterEntry , $prot = 'http://' ) {
if ( substr( $filterEntry, 0, 2 ) == '*.' ) {
$subdomains = true;
$filterEntry = substr( $filterEntry, 2 );
$path = '/';
$host = $filterEntry;
}
- $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
- if ( substr( $host, -1, 1 ) !== '.' ) {
- $host .= '.';
- }
- $like = "$prot://$host";
-
- if ( $subdomains ) {
- $like .= '%';
- }
- if ( !$subdomains || $path !== '/' ) {
- $like .= $path . '%';
+ // Reverse the labels in the hostname, convert to lower case
+ // For emails reverse domainpart only
+ if ( $prot == 'mailto:' && strpos($host, '@') ) {
+ // complete email adress
+ $mailparts = explode( '@', $host );
+ $domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) );
+ $host = $domainpart . '@' . $mailparts[0];
+ $like = "$prot$host%";
+ } elseif ( $prot == 'mailto:' ) {
+ // domainpart of email adress only. do not add '.'
+ $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
+ $like = "$prot$host%";
+ } else {
+ $host = strtolower( implode( '.', array_reverse( explode( '.', $host ) ) ) );
+ if ( substr( $host, -1, 1 ) !== '.' ) {
+ $host .= '.';
+ }
+ $like = "$prot$host";
+
+ if ( $subdomains ) {
+ $like .= '%';
+ }
+ if ( !$subdomains || $path !== '/' ) {
+ $like .= $path . '%';
+ }
}
return $like;
}