* (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 13 Jun 2007 19:47:44 +0000 (19:47 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 13 Jun 2007 19:47:44 +0000 (19:47 +0000)
Regex fragment IP_ADDRESS_STRING was not parenthesized properly, causing the preg_match in IP::isIPAddress() to get false positives on strings which _ended_ in IPv6 subsequences.

RELEASE-NOTES
includes/IP.php

index fd02d7d..8160300 100644 (file)
@@ -163,6 +163,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 9679) Improve documentation for $wgSiteNotice
 * (bug 10215) Show custom editing introduction when editing existing pages
 * (bug 10223) Fix edit link in noarticletext localizations for fr, oc
+* (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
 
 
 == API changes since 1.10 ==
index 8a2756c..de917d6 100644 (file)
@@ -22,7 +22,12 @@ define( 'RE_IPV6_PREFIX', '(12[0-8]|1[01][0-9]|[1-9]?\d)');
 define( 'RE_IPV6_ADD', '(:(:' . RE_IPV6_WORD . '){1,7}|' . RE_IPV6_WORD . '(:{1,2}' . RE_IPV6_WORD . '|::$){1,7})' );
 define( 'RE_IPV6_BLOCK', RE_IPV6_ADD . '\/' . RE_IPV6_PREFIX );
 // This might be useful for regexps used elsewhere, matches any IPv6 or IPv6 address or network
-define( 'IP_ADDRESS_STRING', RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)|' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)');
+define( 'IP_ADDRESS_STRING',
+       '(?:' .
+               RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)' .
+       '|' .
+               RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)' .
+       ')' );
 
 /**
  * A collection of public static functions to play with IP address