Need help with a common php encoding/decoding - $10 to whoever fixes it

Status
Not open for further replies.
Jul 5, 2006
312
1
0
So this is probably one of the most bizarre things I've come across:

Essentailly I have a string this is encoded. I dont know what the encoding is but I need to figure that out. Based on this php document you can see that the encoding is fairly common. Here is the code:

<?
echo "\x3cs\x74\x79\x6c\145\x3e\56\146\145\x65\70a\x63\x340\145\x7b\x62\141\x63\153\x67\162\157\165\156d\x2dp\157s";
?>
<br/>the above should render as normal text in firefox<br/><br/><br/>now check this out:
<?
$string = '"<\x73\164\171\154\x65\x3e\56\x66\x34\x35\70\142\x64b5\x63\x7b\142\141\143k\x67r\157\165\x6e\144\x2dp\157\163","i\164\151\157\156\72\x2d\x31\x32\60p\x78\x20\x30p\170\x3b\x7d.f4\x35\x38\x62\x354\146e{\142\141c","\x6bgr\157\x75\x6e\x64\x2dp\157si\164\151o\x6e\x3a\x2d2\x38\x30p\170\x200\x70\170\x3b\x7d\56\x66\64","\x35\70\x622\x34c\63{b\x61\x63\153\x67r\x6f\x75\x6e\144\55\160o\x73\x69t\x69\x6fn:-280","p\x78 -10\x30\160\x78\73\x7d\56\x66\x34\x35\70b92\x30\70\173bac\x6b\x67r\x6f\165\156\144"';
$ex = explode('","', $string);
echo $ex[0];
?>
<br/>this does not work<br/><br/><br/>however this does:<br/>
<?
echo "<script type='text/javascript'>document.write('".$ex[0]."');</script>";
?>
<br/>so, the very first string php is actually rendering as the decoded text if you look at the source. However, when it's in variable form it doesnt do that. Firefox and all the other browsers apprently have the
So, the most bizarre thing that you will notice is that php actually takes the first string and outputs the correctly decoded string. Furthermore, Firefox 2 renders the third string properly as well when wrapped in the document.write. (Every other browser actually render it properly as well, but this is just a part of the encoded string so they all fail for this truncated string but in general, all of the browsers have support for this encoding). So the question is... what is the mystery encoding?

EDIT: apprently wrapping the encoded string in double quote renders it as normal text in php... so this is some ridiculously common encoding. WHAT IS IT?!?!
 


Figured out, please delete. For anyone curious, you dont need to know a decode function to process the text in php as the real text. When wrapped in double quotes it essentailly becomes the original decoded string. FUcking weird as shit. IF anyone knows what is, post it up for free. :)
 
Code in a string is not parsed unless it's in double quotes. Goes for all control characters like the familiar \n and \tab, escaped quotes, variables, etc.
 
Status
Not open for further replies.