Bug #75431 [Opn->Nab]: False negative filtering a string with short IPv4
| From: | kalle@php.net | Date: | Tue, 24 Oct 2017 22:40:39 +0000 |
| Subject: | Bug #75431 [Opn->Nab]: False negative filtering a string with short IPv4 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212303@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75431&edit=1
ID: 75431
Updated by: kalle@php.net
Reported by: skv at eml dot ru
Summary: False negative filtering a string with short IPv4
-Status: Open
+Status: Not a bug
Type: Bug
Package: Filter related
Operating System: linux (debian/ubuntu)
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The ext/filter extension conforms RFC791 which does not specify any short notation. You may want to
consider using the inet_*() family functions for non standardized conversions.
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2017-10-24 17:50:42] skv at eml dot ru
Description:
------------
---
From manual page: http://www.php.net/filter.filters.validate
---
The FILTER_VALIDATE_IP ignores short notations of IPv4 address (e.g. "127.1") and falsely
reports them to not be valid IP Addresses.
It somehow manages to recognize short forms of IPv6 addresses though (e.g. "::1").
Btw, simple telnet manages to recognize 'em:
$ telnet 127.1 22
Trying 127.0.0.1...
Connected to 127.1.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
Test script:
---------------
#!/bin/bash
php -r 'var_dump( filter_var("127.1", FILTER_VALIDATE_IP) );'
Expected result:
----------------
string(5) "127.1"
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75431&edit=1