Make wfMatchesDomainList not match partial domains
authorKevin Israel <pleasestand@live.com>
Mon, 10 Jun 2013 02:04:24 +0000 (22:04 -0400)
committerRelease notes rebase bot <matma.rex+releasenotesrebasebot@gmail.com>
Sun, 28 Jul 2013 09:18:38 +0000 (11:18 +0200)
Change-Id: I90e7af152fbd9bb8d84d5f2c54bd352b461c530d

RELEASE-NOTES-1.22
includes/GlobalFunctions.php
tests/phpunit/includes/GlobalFunctions/GlobalTest.php

index 2658193..e67bb00 100644 (file)
@@ -39,6 +39,8 @@ production.
   page protection levels. The rights 'editprotected' and 'editsemiprotected'
   are now used for this purpose instead.
 * (bug 40866) wgOldChangeTagsIndex removed.
+* $wgNoFollowDomainExceptions now only matches entire domains. For example,
+  an entry for 'bar.com' will still match 'foo.bar.com' but not 'foobar.com'.
 
 === New features in 1.22 ===
 * (bug 44525) mediawiki.jqueryMsg can now parse (whitelisted) HTML elements and attributes.
index 17835e4..65b4c23 100644 (file)
@@ -879,10 +879,10 @@ function wfMakeUrlIndexes( $url ) {
 function wfMatchesDomainList( $url, $domains ) {
        $bits = wfParseUrl( $url );
        if ( is_array( $bits ) && isset( $bits['host'] ) ) {
+               $host = '.' . $bits['host'];
                foreach ( (array)$domains as $domain ) {
-                       // FIXME: This gives false positives. http://nds-nl.wikipedia.org will match nl.wikipedia.org
-                       // We should use something that interprets dots instead
-                       if ( substr( $bits['host'], -strlen( $domain ) ) === $domain ) {
+                       $domain = '.' . $domain;
+                       if ( substr( $host, -strlen( $domain ) ) === $domain ) {
                                return true;
                        }
                }
index 408d440..57f8c19 100644 (file)
@@ -623,9 +623,7 @@ class GlobalTest extends MediaWikiTestCase {
                                array( "$p//www.example2.com", array( 'www.example.com', 'www.example2.com', 'www.example3.com' ), true, "Exact match with other domains in array, $pDesc URL" ),
                                array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ),
                                array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ),
-
-                               // FIXME: This is a bug in wfMatchesDomainList(). If and when this is fixed, update this test case
-                               array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), true, "Substrings of domains match while they shouldn't, $pDesc URL" ),
+                               array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), false, "Non-matching substring of domain, $pDesc URL" ),
                        ) );
                }