| Newsgroups |
php.pear.bugs |
| Message-ID |
<[email protected]> |
Edit report at https://pear.php.net/bugs/bug.php?id=20421&edit=1
ID: 20421
Comment by: [email protected]
Reported By: jan dot prachar at gmail dot com
Summary: Reject invalid path
Status: Feedback
Type: Bug
Package: Net_URL2
Package Version: 2.0.7
PHP Version: Irrelevant
Assigned To: tkli
Roadmap Versions:
New Comment:
My motivation was seeing this line of code:
https://github.com/pear/Net_URL2/blob/master/Net/URL2.php#L728
and this bug report https://pear.php.net/bugs/bug.php?id=20159
Here you are modifying a path in order to get a valid URI. And I think
that bug #20159 is not bug at all. Th query and fragment has separators
(? and #), but path has not. I think you should compose URI from the
parts as they were set and leave the responsiblity to user of the
library (or notify him by throwing an exception).
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2014-10-08 00:15:22] tkli
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: tkli
what you write is correct in terms of RFC 3986 but unfortunately
Net_URL2 is not about URI
validation (in full or in part). therefore throwing an exception while
calling Net_URL2::setPath() (or
Net_URL2::getUrl() and those by yours correctly named authority
counterparts) could be (at least)
unexpected or just straight forward introduce a new feature.
if you share more about your motivation, it might be possible to find a
beautiful way to keep
Net_URL2 open for extension but closed for modification offering good
options for your validation
needs.
me seeing more context would also allow me to better understand why you
qualified this as a bug.
feedback welcome.
-- tk
------------------------------------------------------------------------
[2014-10-03 00:01:42] pracj3am
As well as when you set path first and then add/remove authority.
------------------------------------------------------------------------
[2014-10-02 23:56:49] pracj3am
Description:
------------
See https://tools.ietf.org/html/rfc3986#section-3.3
Path should be empty or begin with slash if authority is present.
If a URI does not contain an authority component, then the path cannot
begin with two
slash characters.
Test script:
---------------
$url = new Net_URL2('http:g');
$url->setPath('//h');
echo $url->getUrl();
Expected result:
----------------
*exception thrown*
Actual result:
--------------
http://h
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20421&edit=1