php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51305 filter_var returns false on valid URLs
Submitted: 2010-03-16 09:52 UTC Modified: 2010-03-16 10:23 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rakan dot alhneiti at gmail dot com Assigned:
Status: Duplicate Package: Filter related
PHP Version: 5.2.13 OS: Redhat
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rakan dot alhneiti at gmail dot com
New email:
PHP Version: OS:

 

 [2010-03-16 09:52 UTC] rakan dot alhneiti at gmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-16 10:05 UTC] aharvey@php.net
-Status: Open +Status: Duplicate
 [2010-03-16 10:05 UTC] aharvey@php.net
Already fixed in SVN, per bug #51192.
 [2010-03-16 10:07 UTC] jani@php.net
-Status: Duplicate +Status: Feedback
 [2010-03-16 10:07 UTC] jani@php.net
Are you really using 5.2.13? I definately am and this test script of yours returns the url as expected.
 [2010-03-16 10:17 UTC] aharvey@php.net
-Status: Feedback +Status: Duplicate
 [2010-03-16 10:17 UTC] aharvey@php.net
This was fixed after 5.2.13 was released, so yes, 5.2.13 would be affected.
 [2010-03-16 10:23 UTC] rakan dot alhneiti at gmail dot com
yup i've upgraded my version of php a couple of days ago via compiling the latest php 5.2.13 source and this happened. and as you can see the fix came after the release
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 16:01:27 2024 UTC