Bug #53236 [NEW]: IPv6 address validation error

From: Date: Wed, 03 Nov 2010 14:59:05 +0000
Subject: Bug #53236 [NEW]: IPv6 address validation error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155742@lists.php.net to get a copy of this message
From: Operating system: All PHP version: 5.3.3 Package: Filter related Bug Type: Bug Bug description:IPv6 address validation error Description: ------------ IPv6 addresses with a single abbreviated field are being validated inconsistently. For example the following IPv6 address is marked as valid: 1::2:3:4:5:6:7 but the following two IPv6 addresses are marked as invalid: ::1:2:3:4:5:6:7 1:2:3:4:5:6:7:: How should they be validated? The authority on the text representation of IPv6 addresses is RFC 4291, which allows all three examples. However the recently- published RFC 5952 deprecates a format where a single field is abbreviated in this way, although it clearly states that such addresses must be accepted if presented. RFC 5952 defines a recommended formatting for *outputting* IPv6 addresses, not for validating incoming ones. RFC 3986 also allows this syntax, but RFC 5321 does not (although like RFC 5952 it acknowledges the ultimate authority of RFC 4291). The point of this bug report, however, is to point out the inconsistent validation of these addresses. I believe they should all be allowed (as per RFCs 4291 and 3986). Warning: this might result in filter_var allowing some email addresses that have IPv6 address literals that are OK according to RFC 4291 but not RFC 5321. Test script: --------------- <?php function isIP($address) { $valid = filter_var($address, FILTER_VALIDATE_IP); echo "$address is", ($valid ? '' : ' not'), ' valid<br/>'; } isIP('1:2:3::4:5:6:7'); isIP('::1:2:3:4:5:6:7'); isIP('1:2:3:4:5:6:7::'); ?> Expected result: ---------------- 1:2:3::4:5:6:7 is valid ::1:2:3:4:5:6:7 is valid 1:2:3:4:5:6:7:: is valid Actual result: -------------- 1:2:3::4:5:6:7 is valid ::1:2:3:4:5:6:7 is not valid 1:2:3:4:5:6:7:: is not valid -- Edit bug report at http://bugs.php.net/bug.php?id=53236&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53236&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53236&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53236&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53236&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53236&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53236&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53236&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53236&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53236&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53236&r=support Expected behavior: http://bugs.php.net/fix.php?id=53236&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53236&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53236&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53236&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53236&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53236&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53236&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53236&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53236&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53236&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53236&r=mysqlcfg

« previous php.bugs (#155742) next »