Bug Report #3001
Request::$uri changes based on the server.
| Status: | Closed | Start date: | 06/24/2010 | ||
|---|---|---|---|---|---|
| Priority: | High | Due date: | |||
| Assignee: | % Done: | 50% |
|||
| Category: | Core | ||||
| Target version: | v3.0.7 | ||||
| Resolution: | fixed | Points: |
Description
Scenario 1.¶
You have a server with PATH_INFO and request the following URL:
PATH_INFO will contain /ö and thus set Request::$uri to the same value.
Scenario 2.¶
This server doesn't have PATH_INFO, but REQUEST_URI. I request the same URL:
but REQUEST_URI uses the encoded values like so: /%C3%B6.
We have a problem where the Request class is inconsistent. The solution I propose would be to cascade down from using decoded values to encoded values.
Decoded¶
- PHP_SELF
- DOCUMENT_URI
- SCRIPT_NAME
- PATH_INFO
Encoded¶
- REQUEST_URI
I think REQUEST_URI should be used as a last resort. If a user requests /ö then I expect that in the Request class. What if they request /%C3%B6? I still expect /ö in the request class. That's because they're the same, just ones encoded and the other is not.
I think it'd be a far more common scenario for a person to want to use the already decoded values.
Related issues
Associated revisions
Use rawurldecode() on the REQUEST_URI when using it in Request::instance, fixes #3001
History
Updated by Woody Gilk almost 3 years ago
- Assignee set to Woody Gilk
Would using urldecode on $_SERVER['REQUEST_URI'] fix this?
Updated by Mathew Davies almost 3 years ago
I'd prefer rawurldecode. This way the addition character isn't parsed as a space. This will mimic how the server globals act.
URI requested: /%C3%B6%20+
'SCRIPT_NAME' => string '/ö +' (length=5) 'REQUEST_URI' => string '/%C3%B6%20+' (length=11) 'DOCUMENT_URI' => string '/ö +' (length=5) 'PHP_SELF' => string '/ö +' (length=5)
urldecode:
ö<space><space>
I still think using REQUEST_URI last is the optimal solution. The server has already done the work and would require 1 less method call. Either way works for me though.
Updated by Woody Gilk almost 3 years ago
Perfect Mathew, that was exactly the comparison I needed.
Updated by Mathew Davies almost 3 years ago
Just a note, this was running under nginx/0.8.41. Results could vary from server to server.
Updated by Woody Gilk almost 3 years ago
I doubt the results would vary much, this is all RFC specification.
Updated by Woody Gilk almost 3 years ago
- Status changed from New to Needs Test
- Assignee changed from Woody Gilk to Jeremy Bush
- Resolution set to fixed
Updated by Woody Gilk almost 3 years ago
- % Done changed from 0 to 50
Updated by Jeremy Bush almost 3 years ago
What was the reason for using REQUEST_URI as opposed to a "pre-decoded" value?
Updated by Woody Gilk almost 3 years ago
The code in question tests for PATH_INFO,REQUEST_URI, and PHP_SELF to attempt to find the URI. Almost all servers will provide PATH_INFO.
Updated by Woody Gilk almost 3 years ago
- Status changed from Needs Test to Closed
I think this is also the same as #3001, just worded differently.
Updated by Jeremy Bush almost 3 years ago
Ah, it helps if i look what around the changeset :)
btw, this is #3001 :)