Home » HTTP » HTTP » Bug #7130
HTTP::absoluteURI("?foo") resolves to wrong URI
Details
| Submitted | 2006-03-15 19:25 UTC |
|---|---|
| From | pear dot php dot net at chsc dot dk |
| Assigned | mike |
| Status | Closed |
| Package | HTTP |
| PHP Version | 5.0.5 |
| OS | Linux |
| 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().