Bug #80119 [Opn->Nab]: base64_decode accept a malformed input

From: Date: Thu, 17 Sep 2020 22:29:41 +0000
Subject: Bug #80119 [Opn->Nab]: base64_decode accept a malformed input
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229063@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80119&edit=1 ID: 80119 Updated by: cmb@php.net Reported by: contact at roukmoute dot fr Summary: base64_decode accept a malformed input -Status: Open +Status: Not a bug Type: Bug -Package: *Encryption and hash functions +Package: *URL Functions PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php base64_decode() may produce binary data[1] (i.e. a string of bytes, instead of characters in a particular encoding); see <https://3v4l.org/T0jTg>. [1] <https://www.php.net/manual/en/function.base64-decode.php#refsect1-function.base64-decode-returnvalues> Previous Comments: ------------------------------------------------------------------------ [2020-09-17 22:20:17] contact at roukmoute dot fr Description: ------------ I thought base64_decode would return false when a badly encoded string is provided. No difference here in strict mode or not. Test script: --------------- $decodedData = base64_decode('qcOpw6nDqcOpw6k='); if ($decodedData === false) { echo 'Malformed input'; } elseif (base64_decode('qcOpw6nDqcOpw6k=', true) === false) { echo 'Malformed input'; } else { echo $decodedData; } Expected result: ---------------- Malformed input Actual result: -------------- �ééééé ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80119&edit=1

« previous php.bugs (#229063) next »