|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
50 + 27 = ?
Subscribe to this entry?

 [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-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 08 05:01:29 2023 UTC