Doc #77009 [Nab]: base64_decode different behavior in php 5.6 and 7.2
| From: | klewi1983 at wp dot pl | Date: | Sun, 14 Oct 2018 19:51:01 +0000 |
| Subject: | Doc #77009 [Nab]: base64_decode different behavior in php 5.6 and 7.2 | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16075@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77009&edit=1
ID: 77009
User updated by: klewi1983 at wp dot pl
Reported by: klewi1983 at wp dot pl
Summary: base64_decode different behavior in php 5.6 and 7.2
Status: Not a bug
Type: Documentation Problem
Package: *URL Functions
Operating System: Windows 7 x64
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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 ;-)
Previous Comments:
------------------------------------------------------------------------
[2018-10-14 11:03:00] cmb@php.net
Thanks!
The ânewâ behavior is correct according to the documentation;
since $strict is FALSE, invalid Base64 characters are silently
discarded. The following script confirms this:
<?php
$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-13 09:40:15] klewi1983 at wp dot pl
My example file link:
https://drive.google.com/open?id=1gJXkA3iJO-a4Sw1Cy9GdE1SITGxWe2Va
------------------------------------------------------------------------
[2018-10-12 14:56:36] cmb@php.net
> 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-12 14:24:45] klewi1983 at wp dot pl
Description:
------------
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:
---------------
var_dump(base64_decode(file_get_contents("test.bin")));
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...............
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77009&edit=1