php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35649 base64_decode bug
Submitted: 2005-12-12 20:39 UTC Modified: 2005-12-12 21:22 UTC
From: salmon318 at hotmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.1.1 OS: Windows
Private report: No CVE-ID: None
 [2005-12-12 20:39 UTC] salmon318 at hotmail dot com
Description:
------------
Upgraded to 5.1.1 from 5.0.5 and our application was totally broken. We found that base64_decode in 5.1.1 behaves differently than 5.0.5. Basically, if there is a SPACE in the string to be decoded, problem comes up.

There are similar article on version 4.0.x but nothing on 5.1.1 so I think it is not fixed in 5.1.x yet.

Reproduce code:
---------------
Try the following code on both PHP 5.0.5 vs 5.1.1:

<? 
$str = "a bc";
echo base64_decode($str);
?>

You will get different result. This only happens if there is a space. Maybe base64_encode has the similar problem too.



Expected result:
----------------
Php 5.0.5 and below has this result:
k??

Php 5.1.1 got this result:
i?



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-12 20:51 UTC] tony2001@php.net
With "a bc" you'll get the same result as with "abc" because that's the way it should work according to the RFC:
"All line breaks or other characters not found in Table 1 must be ignored by decoding software."
http://www.faqs.org/rfcs/rfc2045.html
 [2005-12-12 21:22 UTC] salmon318 at hotmail dot com
So, are you saying 5.0.5 has base64_decode bug? otherwise, how come the result between two versions are different?
I can't find it in the ChangeLog, please correct me if I am wrong.. thanks.
http://www.php.net/ChangeLog-5.php
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 10:01:24 2019 UTC