Bug->Doc #63290 [Opn]: FILTER_FLAG_PATH_REQUIRED is true even if there is no path

From: Date: Thu, 22 Jul 2021 12:49:12 +0000
Subject: Bug->Doc #63290 [Opn]: FILTER_FLAG_PATH_REQUIRED is true even if there is no path
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18982@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63290&edit=1

 ID:                 63290
 Updated by:         cmb@php.net
 Reported by:        leo at leo-unglaub dot net
 Summary:            FILTER_FLAG_PATH_REQUIRED is true even if there is
                     no path
 Status:             Open
-Type:               Bug
+Type:               Documentation Problem
 Package:            URL related
 Operating System:   Debian Linux
 PHP Version:        5.4.7
 Block user comment: N
 Private report:     N

 New Comment:

Well, in a strict sense you're right, but I don't think we can
change that for BC reasons.  The documentation should clarify that
FILTER_FLAG_PATH_REQUIRED also accepts URLs with an empty path
(path-empty in RFC 3986 parlance).


Previous Comments:
------------------------------------------------------------------------
[2012-10-16 16:42:01] 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.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=63290&edit=1


Thread (1 message)

  • cmb@php.net
  • Unknown Message
    • cmb@php.net
« previous php.doc.bugs (#18982) next »