urlencode and $_GET - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: urlencode and $_GET


Quoted text here. Click to load it

 That's the browser (whichever one you're using) attempting to compensate for
your badly encoded URL. This is not behaviour you should rely on.

 In fact I don't know what browser you're using, because IE, Firefox and Opera
attempt to correct the invalid URL by converting the space to %20, not +.

 Putting that source through an HTML validator (HTML Tidy) produces:

line 1 column 1 - Warning: <a> escaping malformed URI reference

error: <...> escaping malformed URI reference

An URI contains non-authorized characters. Or the quotes around the URI are not

Correct the URI.

error: <a> escaping malformed URI reference

BAD   <a href="http://www.mozilla.org/one space.html">space</a>
GOOD  <a href="http://www.mozilla.org/one%20space.html">space</a>
GOOD  <a href="http://www.mozilla.org/one+space.html">space</a>

BAD   <a href="http://www.w3c.org w3c</a>
GOOD  <a href="http://www.w3c.org ">w3c</a>

For the first example, a space should not be contained in URL. (Even if it
works in all browsers...). This is described in detail in the RFC1738 (Look for

RFC2396 - Uniform Resource Identifiers (URI): Generic Syntax"
RFC1738 - Uniform Resource Locators
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: urlencode and $_GET

sorry, it`s 'one space.html' -> 'one%20space.html' not '+'.

as u said, it's 'unsafe' to use spaces according to the rcf, therefore
the browser encodes them (isn`t that rfc compliant?)

btw: the w3 validator isn't yelling anything by using a space in the
url (html 4.01 strict, xhtml 1.0 strict & transitional).
btw2: %23 gets treated as %23, not #.

Re: urlencode and $_GET

black francis wrote:
Quoted text here. Click to load it
click on this url and the first line tells you the value of $_GET
It says: $_GET is:Array ( [value] => start#end )

So it looks to me like the %23 is treated as #.

Re: urlencode and $_GET

meltedown said the following on 18/11/2005 17:17:
Quoted text here. Click to load it

Yes, but now try echoing $_SERVER["REQUEST_URI"].

It is PHP that translates the octet, not the browser.


Re: urlencode and $_GET

Oli Filth wrote:
Quoted text here. Click to load it
I added the output from $_SERVER["REQUEST_URI"]
to http://reenie.org/test/test16.php?value=start%23end
Just for the hell of it.
I guess the browser didn't change it after all.

Re: urlencode and $_GET

i mean it's treated like '%23' to the browser, not php.
php by default decodes the incoming string (as u realize in the above

Re: urlencode and $_GET

meltedown wrote:


Quoted text here. Click to load it

Well, I had the impression you didn't understand that part.
But appearantly you do.

Quoted text here. Click to load it

This part is where you confused me.
It looks like you want to ADD stuff to the $_GET-array, which doesn't make  
much sense.

Quoted text here. Click to load it

I do not see the problem to be honest.
I just tested on my own machine (PHP5) the follwing:


from php.test:

$id = $_GET["id"];
// ID now contains HJUYH_#4_NAT

Which is excactly what is expected.

So show us some more code.

Erwin Moller

Re: urlencode and $_GET

Erwin Moller wrote:
Quoted text here. Click to load it
Right, I believe you. I know what it is now. Its not a PHP problem, its  
a mod rewrite problem. Sorry, I left it out because I was trying not to  
complicate my explaination.

if I use
it works fine.

but if I use:
The last part gets tuncated into SANROSA_

Here's the rewrite rule :
RewriteRule ([^/]+)/([^/]+)\.html$ /item.php?id=$2&cname=$1

The second ([^/])+ is the culprit, but I'm not sure how to fix it.
Presumably, it doesn't recognize %

Right now I have fixed the problem with a hack
So this example now looks like:

Site Timeline