php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63290 FILTER_FLAG_PATH_REQUIRED is true even if there is no path
Submitted: 2012-10-16 16:42 UTC Modified: -
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: leo at leo-unglaub dot net Assigned:
Status: Open Package: URL related
PHP Version: 5.4.7 OS: Debian Linux
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
30 - 14 = ?
Subscribe to this entry?

 
 [2012-10-16 16:42 UTC] leo at leo-unglaub dot net
Description:
------------
Hey,
if you validate a given url with the function filter_var and the param FILTER_VALIDATE_URL with the flag FILTER_FLAG_PATH_REQUIRED you also get true back if there is no path.

The function is happy with the result if there is a simple / at the end of the function. But thats not a valid path. A valid path would be at least 1 char after the /. I added you some examples below.

thanks and greetings
Leo

Test script:
---------------
php -r 'var_dump(filter_var("http://php.net/", FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));' // <- will be okay, but it's not.

php -r 'var_dump(filter_var("http://php.net/foobar", FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));' // <- that would be okay.

Expected result:
----------------
filter_var() should return false if the path is not given/empty because according to the documentation if forces the requirement of a path.

Actual result:
--------------
filter_var is okay with an url if there is a / at the end.

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Aug 21 19:01:27 2019 UTC