|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75431 False negative filtering a string with short IPv4
Submitted: 2017-10-24 17:50 UTC Modified: 2017-10-24 22:40 UTC
From: skv at eml dot ru Assigned:
Status: Not a bug Package: Filter related
PHP Version: Irrelevant OS: linux (debian/ubuntu)
Private report: No CVE-ID: None
 [2017-10-24 17:50 UTC] skv at eml dot ru
From manual page:

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
Connected to 127.1.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2

Test script:

php -r 'var_dump( filter_var("127.1", FILTER_VALIDATE_IP) );'

Expected result:
string(5) "127.1"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 22:40 UTC]
-Status: Open +Status: Not a bug
 [2017-10-24 22:40 UTC]
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.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 08:01:30 2024 UTC