Bug #80870 [Opn->Fbk]: base64_decode: Concatenated base64 blocks are corrupted
| From: | requinix@php.net | Date: | Mon, 15 Mar 2021 22:20:23 +0000 |
| Subject: | Bug #80870 [Opn->Fbk]: base64_decode: Concatenated base64 blocks are corrupted | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232759@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80870&edit=1
ID: 80870
Updated by: requinix@php.net
Reported by: bugs at jth dot net
Summary: base64_decode: Concatenated base64 blocks are
corrupted
-Status: Open
+Status: Feedback
Type: Bug
-Package: Unknown/Other Function
+Package: Strings related
Operating System: Linux
PHP Version: 7.4.16
Block user comment: N
Private report: N
New Comment:
= is not valid for Base64 when located in the middle of an input string. As such it will be ignored
(since $strict is not being used) and PHP will attempt to decode
"TGluZSBuciAxIGJjZGVmZwoTGluZSBuciAyIAo=".
The line feed is irrelevant.
What is this "may occur as input from an email"?
Previous Comments:
------------------------------------------------------------------------
[2021-03-15 20:28:36] bugs at jth dot net
Description:
------------
When decoding a string containing two or more base64 blocks with line feeds in the base64 text the
latter blocks are corrupted.
This may occur as input from an email generated by some mail programs.
Test script:
---------------
$s1 = base64_encode("Line nr 1 bcdefg\n");
$s2 = base64_encode("Line nr 2 \n");
$str = $s1."\n".$s2;
echo $str
echo base64_decode($str);
Expected result:
----------------
TGluZSBuciAxIGJjZGVmZwo=
TGluZSBuciAyIAo=
Line nr 1 bcdefg
Line nr 2
Actual result:
--------------
Result:
TGluZSBuciAxIGJjZGVmZwo=
TGluZSBuciAyIAo=
Line nr 1 bcdefg
(corrupted text)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80870&edit=1