[PEAR-BUG] Bug #20418 [Fbk]: Incorrect normalization of URI with missing authority
[email protected] Wed, 8 Oct 2014 01:40:55 +0100 (BST)
| Newsgroups | php.pear.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://pear.php.net/bugs/bug.php?id=20418&edit=1 ID: 20418 Updated by: [email protected] Reported By: jan dot prachar at gmail dot com Summary: Incorrect normalization of URI with missing authority Status: Feedback Type: Bug Package: Net_URL2 Package Version: 2.0.7 PHP Version: Irrelevant Assigned To: tkli Roadmap Versions: New Comment: you're right my description was not very good. "http:g" is a valid URI scheme: "http" path-rootless: "g" so this is not a validation issue. I was wrong on that part. not yet sure how normalization should work here. how did you run over this issue? Previous Comments: ------------------------------------------------------------------------ [2014-10-08 01:21:09] pracj3am I don't understand, http:g is completely valid URI, isn't? Another examples: > echo (new Net_URL2('mailto:[email protected]'))->getNormalizedURL(); mailto:///[email protected] > echo (new Net_URL2('urn:oasis:names:specification:docbook:dtd:xml:4.1.2'))->getNormalizedURL(); urn:///oasis:names:specification:docbook:dtd:xml:4.1.2 ------------------------------------------------------------------------ [2014-10-08 00:45:45] tkli -Status: Open +Status: Feedback -Assigned To: +Assigned To: tkli "http:g" is not a valid URI. the parser within Net_URL2 is lax accepting this as input (e.g. within the ctor) and (as best guess) maps the end "g" to the path component (actually treating the malformed hier-part as path component). for the case you bring up here - the "missing authority" - normalization can only follow the rules as outlined in RFC 3986 Section 6. Normalization and Comparison. these are based upon what the ctor has initialized as URI parts then. as such URI normalization needs to create a "valid" URI (which is not a valid HTTP scheme URI, it does not have a by scheme federated empty authority as you correctly noted, compare #20304 for the file scheme) and "http:g" is not such a valid URI, it *can not be* the expected result of Net_URL2::getNormalizedURL(). this in its own would qualify your report as invalid, however this does not resolve the underlying problem for you that Net_URL2 does not validate URIs (it parses those and it does normalization). compare with your other report #20421. if you can share why you expected that result (in the other report you wrote you want to see an exception thrown, with such a feature, this must have happened already when instantiating Net_URL2 for the example you give in this report). with some more context, it might be easier to understand for me. feedback welcome. -- tk ------------------------------------------------------------------------ [2014-10-02 23:10:49] pracj3am Description: ------------ Normalization of URI with missing authority sets the authority to empty string (which is invalid for http scheme) and ads slash to the beginning of the path. Test script: --------------- echo (new Net_URL2('http:g'))->getNormalizedURL(); Expected result: ---------------- http:g Actual result: -------------- http:///g ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=20418&edit=1