svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/filter/logical_filters.c branches/PHP_5_3/ext/filter/tests/018.phpt
branches/PHP_5_3/ext/filter/tests/bug53150.phpt trunk/ext/filter/logical_filters.c trunk/ext/filter/tests/018.phpt
trunk/ext/filter/tests/bug53150.phpt
| From: | Ilia Alshanetsky | Date: | Sun, 12 Dec 2010 18:36:21 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/filter/logical_filters.c branches/PHP_5_3/ext/filter/tests/018.phpt branches/PHP_5_3/ext/filter/tests/bug53150.phpt trunk/ext/filter/logical_filters.c trunk/ext/filter/tests/018.phpt trunk/ext/filter/tests/bug53150.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-64109@lists.php.net to get a copy of this message | ||
iliaa Sun, 12 Dec 2010 18:36:21 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=306282
Log:
Fixed bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges)
Bug: http://bugs.php.net/53150 (Open) 127.0.0.1 is valid
with FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGE
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c
U php/php-src/branches/PHP_5_3/ext/filter/tests/018.phpt
A php/php-src/branches/PHP_5_3/ext/filter/tests/bug53150.phpt
U php/php-src/trunk/ext/filter/logical_filters.c
U php/php-src/trunk/ext/filter/tests/018.phpt
A php/php-src/trunk/ext/filter/tests/bug53150.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-12-12 18:27:59 UTC (rev 306281)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-12-12 18:36:21 UTC (rev 306282)
@@ -6,6 +6,10 @@
- Zend Engine:
. Indirect reference to $this fails to resolve if direct $this is never used
in method. (Scott)
+
+- Filter extension:
+ . Fixed bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges).
+ (Ilia)
- Intl extension:
. Fixed bug #53512 (NumberFormatter::setSymbol crash on bogus $attr values).
Modified: php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c 2010-12-12 18:27:59 UTC (rev 306281)
+++ php/php-src/branches/PHP_5_3/ext/filter/logical_filters.c 2010-12-12 18:36:21 UTC (rev 306282)
@@ -710,8 +710,11 @@
if (flags & FILTER_FLAG_NO_RES_RANGE) {
if (
(ip[0] == 0) ||
+ (ip[0] == 128 && ip[1] == 0) ||
+ (ip[0] == 191 && ip[1] == 255) ||
(ip[0] == 169 && ip[1] == 254) ||
(ip[0] == 192 && ip[1] == 0 && ip[2] == 2) ||
+ (ip[0] == 127 && ip[1] == 0 && ip[2] == 0 && ip[3] == 1) ||
(ip[0] >= 224 && ip[0] <= 255)
) {
RETURN_VALIDATION_FAILED
@@ -732,6 +735,9 @@
RETURN_VALIDATION_FAILED
}
}
+ if (flags & FILTER_FLAG_NO_RES_RANGE && Z_STRLEN_P(value) == 3 &&
!strcmp("::1", Z_STRVAL_P(value))) {
+ RETURN_VALIDATION_FAILED
+ }
}
break;
}
Modified: php/php-src/branches/PHP_5_3/ext/filter/tests/018.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/filter/tests/018.phpt 2010-12-12 18:27:59 UTC (rev 306281)
+++ php/php-src/branches/PHP_5_3/ext/filter/tests/018.phpt 2010-12-12 18:36:21 UTC (rev 306282)
@@ -37,7 +37,7 @@
string(9) "127.0.0.1"
bool(false)
string(12) "192.0.34.166"
-string(9) "127.0.0.1"
+bool(false)
string(9) "192.0.0.1"
string(12) "192.0.34.166"
bool(false)
Added: php/php-src/branches/PHP_5_3/ext/filter/tests/bug53150.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/filter/tests/bug53150.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/filter/tests/bug53150.phpt 2010-12-12 18:36:21 UTC (rev 306282)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP));
+var_dump(filter_var("::1", FILTER_VALIDATE_IP));
+
+var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+var_dump(filter_var('::1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+
+var_dump(filter_var('128.0.0.1', FILTER_VALIDATE_IP));
+var_dump(filter_var('128.0.0.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+
+var_dump(filter_var('191.255.0.0', FILTER_VALIDATE_IP));
+var_dump(filter_var('191.255.0.0', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+
+?>
+--EXPECT--
+string(9) "127.0.0.1"
+string(3) "::1"
+bool(false)
+bool(false)
+string(9) "128.0.0.1"
+bool(false)
+string(11) "191.255.0.0"
+bool(false)
Modified: php/php-src/trunk/ext/filter/logical_filters.c
===================================================================
--- php/php-src/trunk/ext/filter/logical_filters.c 2010-12-12 18:27:59 UTC (rev 306281)
+++ php/php-src/trunk/ext/filter/logical_filters.c 2010-12-12 18:36:21 UTC (rev 306282)
@@ -710,8 +710,11 @@
if (flags & FILTER_FLAG_NO_RES_RANGE) {
if (
(ip[0] == 0) ||
+ (ip[0] == 128 && ip[1] == 0) ||
+ (ip[0] == 191 && ip[1] == 255) ||
(ip[0] == 169 && ip[1] == 254) ||
(ip[0] == 192 && ip[1] == 0 && ip[2] == 2) ||
+ (ip[0] == 127 && ip[1] == 0 && ip[2] == 0 && ip[3] == 1) ||
(ip[0] >= 224 && ip[0] <= 255)
) {
RETURN_VALIDATION_FAILED
@@ -732,6 +735,9 @@
RETURN_VALIDATION_FAILED
}
}
+ if (flags & FILTER_FLAG_NO_RES_RANGE && Z_STRLEN_P(value) == 3 &&
!strcmp("::1", Z_STRVAL_P(value))) {
+ RETURN_VALIDATION_FAILED
+ }
}
break;
}
Modified: php/php-src/trunk/ext/filter/tests/018.phpt
===================================================================
--- php/php-src/trunk/ext/filter/tests/018.phpt 2010-12-12 18:27:59 UTC (rev 306281)
+++ php/php-src/trunk/ext/filter/tests/018.phpt 2010-12-12 18:36:21 UTC (rev 306282)
@@ -37,7 +37,7 @@
string(9) "127.0.0.1"
bool(false)
string(12) "192.0.34.166"
-string(9) "127.0.0.1"
+bool(false)
string(9) "192.0.0.1"
string(12) "192.0.34.166"
bool(false)
Added: php/php-src/trunk/ext/filter/tests/bug53150.phpt
===================================================================
--- php/php-src/trunk/ext/filter/tests/bug53150.phpt (rev 0)
+++ php/php-src/trunk/ext/filter/tests/bug53150.phpt 2010-12-12 18:36:21 UTC (rev 306282)
@@ -0,0 +1,28 @@
+--TEST--
+Bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP));
+var_dump(filter_var("::1", FILTER_VALIDATE_IP));
+
+var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+var_dump(filter_var('::1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+
+var_dump(filter_var('128.0.0.1', FILTER_VALIDATE_IP));
+var_dump(filter_var('128.0.0.1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+
+var_dump(filter_var('191.255.0.0', FILTER_VALIDATE_IP));
+var_dump(filter_var('191.255.0.0', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
+
+?>
+--EXPECT--
+string(9) "127.0.0.1"
+string(3) "::1"
+bool(false)
+bool(false)
+string(9) "128.0.0.1"
+bool(false)
+string(11) "191.255.0.0"
+bool(false)