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
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

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.