Bug #51305 [NEW]: filter_var returns false on valid URLs

From: Date: Tue, 16 Mar 2010 08:52:51 +0000
Subject: Bug #51305 [NEW]: filter_var returns false on valid URLs
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148661@lists.php.net to get a copy of this message
From:             
Operating system: Redhat
PHP version:      5.2.13
Package:          Filter related
Bug Type:         Bug
Bug description:filter_var returns false on valid URLs

Description:
------------
Hello,

I am currently testing script attached which is supposed to validate URLs

The URL as you can see is a valid URL but the 4 var_dump's done return
false. Here is a test run result:

string(29) "http://my-domain.mydomain.com"
bool(false)
bool(false)
bool(false)
bool(false)

I tested my_domain.mydomain.com and it returned the domain correctly. while
on the '-' dash sign it returns false


Test script:
---------------
<?php
        $URL = "http://my-domain.mydomain.com";
        var_dump($URL);
        var_dump(filter_var($URL, FILTER_VALIDATE_URL));
        var_dump(filter_var($URL, FILTER_VALIDATE_URL,
FILTER_FLAG_SCHEME_REQUIRED));
        var_dump(filter_var($URL, FILTER_VALIDATE_URL,
FILTER_FLAG_HOST_REQUIRED));
        var_dump(filter_var($URL, FILTER_VALIDATE_URL,
FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED));
?>

Expected result:
----------------
return the URL in case it is valid even if it contains '-'

Actual result:
--------------
returns false

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51305&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51305&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51305&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51305&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51305&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51305&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51305&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51305&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51305&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51305&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51305&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51305&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51305&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51305&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51305&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51305&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51305&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51305&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51305&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51305&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51305&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51305&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#148661) next »