r22969 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22968‎ | r22969 | r22970 >
Date:19:47, 13 June 2007
Author:brion
Status:old
Tags:
Comment:
* (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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/IP.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/IP.php
@@ -22,7 +22,12 @@
2323 define( 'RE_IPV6_ADD', '(:(:' . RE_IPV6_WORD . '){1,7}|' . RE_IPV6_WORD . '(:{1,2}' . RE_IPV6_WORD . '|::$){1,7})' );
2424 define( 'RE_IPV6_BLOCK', RE_IPV6_ADD . '\/' . RE_IPV6_PREFIX );
2525 // This might be useful for regexps used elsewhere, matches any IPv6 or IPv6 address or network
26 -define( 'IP_ADDRESS_STRING', RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)|' . RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)');
 26+define( 'IP_ADDRESS_STRING',
 27+ '(?:' .
 28+ RE_IP_ADD . '(\/' . RE_IP_PREFIX . '|)' .
 29+ '|' .
 30+ RE_IPV6_ADD . '(\/' . RE_IPV6_PREFIX . '|)' .
 31+ ')' );
2732
2833 /**
2934 * A collection of public static functions to play with IP address
Index: trunk/phase3/RELEASE-NOTES
@@ -163,6 +163,7 @@
164164 * (bug 9679) Improve documentation for $wgSiteNotice
165165 * (bug 10215) Show custom editing introduction when editing existing pages
166166 * (bug 10223) Fix edit link in noarticletext localizations for fr, oc
 167+* (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
167168
168169
169170 == API changes since 1.10 ==

Follow-up revisions

RevisionCommit summaryAuthorDate
r23039Merged revisions 22967-23037 via svnmerge from...david20:15, 16 June 2007

Status & tagging log