Doc #77009 [Opn->Nab]: base64_decode different behavior in php 5.6 and 7.2

From: Date: Sun, 14 Oct 2018 11:03:00 +0000
Subject: Doc #77009 [Opn->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-16074@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 Updated by: cmb@php.net Reported by: klewi1983 at wp dot pl Summary: base64_decode different behavior in php 5.6 and 7.2 -Status: Open +Status: Not a bug Type: Documentation Problem Package: *URL Functions Operating System: Windows 7 x64 PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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)); Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#16074) next »