PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP » Bug #7130

HTTP::absoluteURI("?foo") resolves to wrong URI

Details

Submitted2006-03-15 19:25 UTC
Frompear dot php dot net at chsc dot dk
Assignedmike
StatusClosed
PackageHTTP
PHP Version5.0.5
OSLinux
Roadmaps(Not assigned)

Comments

[2006-03-15 19:25 UTC] pear dot php dot net at chsc dot dk

Description:
------------
When HTTP::absoluteURI("?bar") is called from the script <http://example.org/foo.php>, it returns "http://example.org/?bar". According to RFC 3986, it should return "http://example.org/foo.php?bar".

RFC 3986, section 5.4 mentions an example: When the base URL is <http://a/b/c/d;p?q> and the relative URI is <?y>, the target URL is <http://a/b/c/d;p?y>.

Test script:
---------------
Put the following in a file foo.php:

<?php
require_once "HTTP.php";
$uri = "?bar";
print HTTP::absoluteURI($uri);
print " <a href='$uri'>link</a>";
?>

Expected result:
----------------
http://example.org/foo.php?bar link

Actual result:
--------------
http://example.org/?bar link

Note that Firefox 1.5 and Internet Explorer 6 resolves the link correctly to <http://example.org/foo.php?bar>.

[2006-03-15 21:23 UTC] pear dot php dot net at chsc dot dk

Protocol-relative URIs (e.g. <//php.net>) aren't supported either.

Section 5.2 in RFC 3986 describes an algorithm for resolving relative URIs. I think it is fairly simple to implement this using PHP's parse_uri().