[PHP-BUG] Bug #53150 [NEW]: 127.0.0.1 is valid with FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGE

2010-10-25 Thread mentalstring+phpnet at gmail dot com
From: 
Operating system: linux
PHP version:  5.3.3
Package:  Filter related
Bug Type: Bug
Bug description:127.0.0.1 is valid with 
FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGE

Description:

The 127.0.0.1 IP address is considered to be valid even when filtering with
either 

the FILTER_FLAG_NO_RES_RANGE and FILTER_FLAG_NO_PRIV_RANGE flags.



This might be related with bug #47435.

Test script:
---
var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP)); // true

var_dump(filter_var("::1", FILTER_VALIDATE_IP)); // true



var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_RES_RANGE)); // false

var_dump(filter_var('::1', FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE));
// false



var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_PRIV_RANGE));

var_dump(filter_var('::1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_PRIV_RANGE));



Expected result:

true

true

false

false

false

false

Actual result:
--
true

true

false

false

false

false

-- 
Edit bug report at http://bugs.php.net/bug.php?id=53150&edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53150&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53150&r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=53150&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53150&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53150&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53150&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=53150&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=53150&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=53150&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=53150&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=53150&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=53150&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=53150&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53150&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=53150&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=53150&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=53150&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=53150&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=53150&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=53150&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=53150&r=mysqlcfg



Bug #53150 [Opn]: 127.0.0.1 is valid with FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGE

2010-10-25 Thread mentalstring+phpnet at gmail dot com
Edit report at http://bugs.php.net/bug.php?id=53150&edit=1

 ID: 53150
 User updated by:mentalstring+phpnet at gmail dot com
 Reported by:mentalstring+phpnet at gmail dot com
 Summary:127.0.0.1 is valid with
 FILTER_FLAG_NO_PRIV_RANGE/FILTER_FLAG_NO_RES_RANGE
 Status: Open
 Type:   Bug
 Package:Filter related
 Operating System:   linux
 PHP Version:5.3.3
 Block user comment: N

 New Comment:

Apologies, entered the wrong output values.



Expected result:



string(9) "127.0.0.1"

string(3) "::1"

bool(false)

bool(false)

bool(false)

bool(false)









Actual result:



string(9) "127.0.0.1"

string(3) "::1"

string(9) "127.0.0.1"

string(3) "::1"

string(9) "127.0.0.1"

string(3) "::1"





The IP address 127.0.0.1 might be a special IP - not quite sure if it
fits in 

the private range, or the reserved range. Or perhaps, there should be a
special 

range for this special cases.


Previous Comments:
--------------------
[2010-10-25 16:01:14] mentalstring+phpnet at gmail dot com

Description:

The 127.0.0.1 IP address is considered to be valid even when filtering
with either 

the FILTER_FLAG_NO_RES_RANGE and FILTER_FLAG_NO_PRIV_RANGE flags.



This might be related with bug #47435.

Test script:
---
var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP)); // true

var_dump(filter_var("::1", FILTER_VALIDATE_IP)); // true



var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_RES_RANGE)); // false

var_dump(filter_var('::1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_RES_RANGE)); // false



var_dump(filter_var('127.0.0.1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_PRIV_RANGE));

var_dump(filter_var('::1', FILTER_VALIDATE_IP,
FILTER_FLAG_NO_PRIV_RANGE));



Expected result:

true

true

false

false

false

false

Actual result:
--
true

true

false

false

false

false






-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53150&edit=1