Bug #75431 [NEW]: False negative filtering a string with short IPv4

From: Date: Tue, 24 Oct 2017 17:50:49 +0000
Subject: Bug #75431 [NEW]: False negative filtering a string with short IPv4
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212288@lists.php.net to get a copy of this message
From:             skv at eml dot ru
Operating system: linux (debian/ubuntu)
PHP version:      Irrelevant
Package:          Filter related
Bug Type:         Bug
Bug description:False negative filtering a string with short IPv4

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 bug report at https://bugs.php.net/bug.php?id=75431&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=75431&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=75431&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=75431&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=75431&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=75431&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=75431&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=75431&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=75431&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=75431&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=75431&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=75431&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=75431&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=75431&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75431&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=75431&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=75431&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=75431&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75431&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=75431&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=75431&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#212288) next »