#36946 [Bgs]: base64_decode doesn't work

From: Date: Sun, 02 Apr 2006 12:13:03 +0000
Subject: #36946 [Bgs]: base64_decode doesn't work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95211@lists.php.net to get a copy of this message
ID: 36946 Updated by: mike@php.net Reported By: kirlo at gmx dot de Status: Bogus Bug Type: *URL Functions Operating System: windows & debian PHP Version: 5.1.2 New Comment: Don't urldecode $_GET variables and keep in mind taht most servers have an URL lenght limit. Previous Comments: ------------------------------------------------------------------------ [2006-04-02 13:37:51] kirlo at gmx dot de ok, this time i took the string and used base64 encoding and then i urlencoded that base64 output. i sent this "double encoded" string to the server via POST/GET and there i used this script: <?php echo base64_decode(urldecode($_GET[vari])); ?> and nothing changed. the first lines are ok but then the text is messed up. (you might think, that the base64 encoding function on my client application does not work properly, but as i mentioned before i've already tested the output with other base64 decoder and they hat no problems) ------------------------------------------------------------------------ [2006-04-02 13:24:30] tony2001@php.net You must use urldecode() on the data you're sending through GET/POST. No bug here. ------------------------------------------------------------------------ [2006-04-02 13:18:23] kirlo at gmx dot de yes, we've already tried urlencoding as an alternative and urldecode works. but there's still the base64_decode bug when you send the data via POST or GET. as i mentioned before, it worked under php4 and the earlier php5 versions. ------------------------------------------------------------------------ [2006-04-02 13:08:42] tony2001@php.net What if you use urlencode($data) ? ------------------------------------------------------------------------ [2006-04-02 12:10:02] kirlo at gmx dot de well that's mysterious - this script will work without any problems (put my base64encoded.txt into the scriptdir): <?php $fp = fopen ("base64encoded.txt", "r"); $str = fread ($fp, filesize ("base64encoded.txt")); fclose ($fp); echo base64_decode($str); ?> but if you send the string via POST or GET, you'll get this output, where the text ist messed up (copy the content of base64encoded.txt and put it behind yourscript.php?vari= ): <?php echo base64_decode($_GET[vari]); ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/36946 -- Edit this bug report at http://bugs.php.net/?id=36946&edit=1

« previous php.bugs (#95211) next »