|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77009 base64_decode different behavior in php 5.6 and 7.2
Submitted: 2018-10-12 14:24 UTC Modified: 2018-10-14 21:40 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: klewi1983 at wp dot pl Assigned:
Status: Re-Opened Package: *URL Functions
PHP Version: Irrelevant OS: Windows 7 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
22 - 10 = ?
Subscribe to this entry?

 [2018-10-12 14:24 UTC] klewi1983 at wp dot pl
XAMPP 5.6.31 32bit:
PHP 5.6.31 (cli) (built: Jul  5 2017 22:25:43)

XAMPP 7.2.10, both 32 bit:
PHP 7.2.10 (cli) (built: Sep 13 2018 01:01:10) ( ZTS MSVC15 (Visual C++ 2017) x86 )

My test file (test.bin) size is 123 KB.
How can I attach it to the bug?

Test script:

Expected result:
string(0) ""

Actual result:
result in PHP 5.6.31:
string(0) ""

result in PHP 7.2.10:
string(22534) "Yt       yeN)O?←┬ÁuAŞČ7L...............


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-12 14:56 UTC]
> My test file (test.bin) size is 123 KB.
> How can I attach it to the bug?

Please make the file available for download.
 [2018-10-13 09:40 UTC] klewi1983 at wp dot pl
My example file link:
 [2018-10-14 11:03 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2018-10-14 11:03 UTC]

The “new” behavior is correct according to the documentation;
since $strict is FALSE, invalid Base64 characters are silently
discarded.  The following script confirms this:

    $data = file_get_contents("test.bin");
    $stripped = preg_replace('/[^A-Za-z0-9+\/]/', '', $data);
    var_dump(base64_decode($data) === base64_decode($stripped, true));
 [2018-10-14 19:51 UTC] klewi1983 at wp dot pl
Thanks for the explanation, however, it would be useful to mention the difference in the operation of the function in the document describing migration from php 5.6 to 7.0, or 7.2 to 7.3 ;-)
 [2018-10-14 21:34 UTC]
-Status: Not a bug +Status: Re-Opened
 [2018-10-14 21:34 UTC]
Well, we usually don't document bugfixes in the PHP manual. I'm
not sure, though, whether this has been a bugfix, or a change, so
I'm re-opening.
 [2018-10-14 21:40 UTC]
-Assigned To: cmb +Assigned To:
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 09 19:05:54 2022 UTC