Jump to content

Sending %00 as a part of GET parameter


chombium

Recommended Posts

Hi,

 

I have a php script which gets several parameters over $_GET.

 

For one of them I need to send URL encoded ASCII special characters.

For example:

%00 (url encoded NULL character).

%1B%40 (url encoded Euro sign)

 

When I'm trying to send something the php it self does some conversion and I can not

send the characters which have two byte code (heigher than 127), ie %00%1b%40

 

The conversion that php makes is

"%00" => "\0"

 

Without doing any conversion, when I try echo $_GET["param"] it prints the "\0".

 

Is there a way to get the value of the variable in "raw format", to be the same

as it was put in the URL as a GET parameter?

 

BR, chombium

 

 

Link to comment
https://forums.phpfreaks.com/topic/75180-sending-00-as-a-part-of-get-parameter/
Share on other sites

Thanks for the reply. You saved me ;)

I could see that $_GET does something with the variables, but I was not sure what.

 

I've created a test script:

<?php
echo "original get: ".$_GET["var"]." raw encoded: ".rawurlencode($_GET["var"])."<br/>";
?>

 

and I called it with http://localhost/test.php?var=%00

 

I made some test with various special characters and I experienced some

strange things when testing with %00

 

When I tested on PHP4 (4.3.10 and 4.4.2) I experienced some weird PHP behavior:

$_GET["var"] was "\0" this was expected, but  rawurlencode($_GET["var"]) was "%5C0".

The "\" was urlencoded as %5C

 

On PHP5 (5.2.3 and 5.0.3) it worked good

$_GET["var"] was "\0" and rawurlencode($_GET["var"]) was "%00".

 

Is this a bug in PHP4?

 

TIA, chombium

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.