php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63229 filter_var just hangs up
Submitted: 2012-10-06 11:32 UTC Modified: 2012-10-06 12:38 UTC
From: shabbirbhimani at gmail dot com Assigned:
Status: Not a bug Package: filter (PECL)
PHP Version: 5.3.17 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: shabbirbhimani at gmail dot com
New email:
PHP Version: OS:

 

 [2012-10-06 11:32 UTC] shabbirbhimani at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.filter-var#refsect1-function.filter-var-description
---

When we are behind a web proxy the filter_var just does not return and just ends. To test I am using the web proxy 186.42.212.236 port 3128

And when I run the test script output is

start > x_fwded_4 > filtering

where as expected output should be returning value from the function filter_var anything from the function and control should progress further.

Test script:
---------------

<?php
echo 'start';
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
echo ' > x_fwded_4';
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if (isset($_SERVER['HTTP_CLIENT_IP']))
{
echo ' > client_ip';
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else if (isset($_SERVER['HTTP_FROM']))
{
echo ' > from';
$ip = $_SERVER['HTTP_FROM'];
}
else
{
echo ' > remote';
$ip = $_SERVER['REMOTE_ADDR'];
}
echo ' > filtering';
filter_var($ip, FILTER_VALIDATE_IP);
echo ' > end';
?>

Expected result:
----------------
filter_var function should return and not die or exit.

Actual result:
--------------
start > x_fwded_4 > filtering

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-06 11:39 UTC] pajoye@php.net
pls try only:

filter_var($ip, FILTER_VALIDATE_IP);

set the value of $ip set to what you use.

I can't reproduce any blocking issue or whatever else closed to that.
 [2012-10-06 11:39 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2012-10-06 11:45 UTC] shabbirbhimani at gmail dot com
Even the $ip = '117.194.35.193'; which is my IP reproduces the same.

You can see the script in action here

http://www.fachinformatiker.de/shab.php

I have added phpinfo at the end and let me know if you are able to see it or not?
 [2012-10-06 11:45 UTC] shabbirbhimani at gmail dot com
-Status: Feedback +Status: Open
 [2012-10-06 12:05 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2012-10-06 12:05 UTC] pajoye@php.net
Try using CLI in a console:

php 63229.php

nothing in filter has something to do with network connection.
 [2012-10-06 12:37 UTC] shabbirbhimani at gmail dot com
-Status: Feedback +Status: Open
 [2012-10-06 12:37 UTC] shabbirbhimani at gmail dot com
The issue occurs when you are behind a proxy. Also FILTER is not blank and even adding Option like FILTER_NULL_ON_FAILURE does not help either.
 [2012-10-06 12:38 UTC] pajoye@php.net
Nothing to do with PHP's filter var, sorry.

If you give a one line script using only a constant string with the IP and you can 
reproduce a problem in CLI, then please reopen this bug.
 [2012-10-06 12:38 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 21:03:34 2021 UTC