php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25804 _SERVER['REQUEST_URI'] does not capture fragment
Submitted: 2003-10-09 09:31 UTC Modified: 2003-10-09 10:09 UTC
From: greg at freephile dot com Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 4.3.3 OS: RH Linux 8.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: greg at freephile dot com
New email:
PHP Version: OS:

 

 [2003-10-09 09:31 UTC] greg at freephile dot com
Description:
------------
When a URI includes a fragment, that fragment is not captured as part of the $_SERVER['REQUEST_URI'] variable, so it is not possible to use parse_url() to get the fragment.  As an example,  the following request will NOT have the fragment in the $_SERVER['REQUEST_URI'] variable:
http://www.freephile.com/admin/test.php?foo=bar#fragment

Instead, the $_SERVER['REQUEST_URI'] is given as '/admin/test.php?foo=bar'

I use PHP to process outgoing site links on http://www.buzgate.org, but due to this problem, I cannot redirect to external URIs containing a fragment.  The workaround is to recode those URIs into two querystring variables and then reconstruct the URI: to=http://somewhere.com/somepage.html&fragment=named_anchor

$externalSiteURI = $_REQUEST['to'] . $_REQUEST['fragment'];

Reproduce code:
---------------
See
http://www.freephile.com/admin/test.php?foo=bar#fragment

and 
http://buzgate.org/referral.php?to=http://www.sba.gov/library/pubs.html#success4
(this link may be fixed with a workaround by the time you get this message)

Expected result:
----------------
$_SERVER['REQUEST_URI'] = '/admin/test.php?foo=bar#fragment'

Actual result:
--------------
$_SERVER['REQUEST_URI'] = '/admin/test.php?foo=bar'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-09 10:09 UTC] edink@php.net
Browsers never send this part of URI to the server so there is no way it can be "captured".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 13:01:29 2024 UTC