From: Brion Vibber Date: Wed, 13 Jun 2007 19:47:44 +0000 (+0000) Subject: * (bug 10247) Fix IP address regex to avoid false positive IPv6 matches X-Git-Tag: 1.31.0-rc.0~52555 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=d5a8cc2dd1c15e07beaf2f1468e2b775dc8e812a;p=lhc%2Fweb%2Fwiklou.git * (bug 10247) Fix IP address regex to avoid false positive IPv6 matches 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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fd02d7d573..8160300c63 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/IP.php b/includes/IP.php index 8a2756c9da..de917d6da4 100644 --- a/includes/IP.php +++ b/includes/IP.php @@ -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