[PEAR-BUG] Bug #20420 [Csd]: Inconsistent setAuthority and getAuthority

[email protected] Wed, 8 Oct 2014 20:59:45 +0100 (BST)
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at https://pear.php.net/bugs/bug.php?id=20420&edit=1

 ID:               20420
 Updated by:       [email protected]
 Reported By:      jan dot prachar at gmail dot com
 Summary:          Inconsistent setAuthority and getAuthority
 Status:           Closed
 Type:             Bug
 Package:          Net_URL2
 Package Version:  2.0.7
 PHP Version:      Irrelevant
 Assigned To:      tkli
 Roadmap Versions: 
 New Comment:

this is sort-of a right observation (sharp eyes you have ;) ).

removing these lines won't make even any of the tests fail.

however, this deals with the default authority federated by the
file-scheme.

it allows for example to create file URIs easily from a concrete file
name:

    $file = 'some/path/to/file';
    $url  = new Net_URL2('file:' . $file);

that is just prefixing an existing path. for windows you only need to
change "\" into "/".

e.g. when you use a base-uri of a document both in context of file-names
to be used with PHP (via 
file:// stream-wrapper) and within for example the document object
model.

it's not documented so far.

and the example is a little moot in the light of RFC 3986: no authority
would mean empty authority.

however in context of PHP, the empty authority is required. E.g.
"file:/path/to/file" does *not* 
work, 
"file:///path/to/file" does work.

so this is to be interoperable with PHP stream-wrappers:

    $result = file_get_contents($url);


Previous Comments:
------------------------------------------------------------------------

[2014-10-08 18:31:21] pracj3am

btw now you can remove lines 702-704
https://github.com/pear/Net_URL2/blob/master/Net/URL2.php#L702

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

[2014-10-08 01:55:38] tkli

-Status: Assigned
+Status: Closed
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/get/

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

[2014-10-07 18:30:30] tkli

-Assigned To:
+Assigned To: tkli
authority is kept as a compound field of _userinfo, _host and _port.

setting it to an zero-length string is the same as setting the host to a
zero-length string.

it will unset (empty) _userinfo and _port then, too.

this fixes your reported issue.

it will be fixed in the next release.

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

[2014-10-02 23:44:54] pracj3am

Description:
------------
There is difference between no authority (e.g. relative URI) and empty
authority.

Test script:
---------------
$url = new Net_URL2('');
$url->setAuthority('');
var_dump($url->getAuthority());

Expected result:
----------------
string(0) ""

Actual result:
--------------
bool(false)

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


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