Bug #72264 [Opn]: base64_decode $strict fails with whitespace between padding
| From: | cmb@php.net | Date: | Thu, 16 Jun 2016 12:51:09 +0000 |
| Subject: | Bug #72264 [Opn]: base64_decode $strict fails with whitespace between padding | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201676@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72264&edit=1
ID: 72264
Updated by: cmb@php.net
Reported by: lauri dot kentta at gmail dot com
Summary: base64_decode $strict fails with whitespace between
padding
Status: Open
Type: Bug
Package: Strings related
PHP Version: 7.0.6
Block user comment: N
Private report: N
New Comment:
> Whitespace (at least line breaks) is allowed in Base64.
Line breaks are allowed, but as far as I know, not in arbitrary
places, and no other whitespace characters are allowed.
> In other words, base64_decode("VV ==") and base64_decode("VV=
> =") should yield the same result.
ACK. Obviously that is not the case now: <https://3v4l.org/4ZV7T>.
Previous Comments:
------------------------------------------------------------------------
[2016-06-14 15:20:45] lauri dot kentta at gmail dot com
Whitespace (at least line breaks) is allowed in Base64.
And even with your logic, at least the whitespace should be handled equally in all cases. In other
words, base64_decode("VV ==") and base64_decode("VV= =") should yield the same
result.
------------------------------------------------------------------------
[2016-06-14 13:14:20] cmb@php.net
In my opinion, this is not a bug, but rather expected behavior[1]:
| Returns FALSE if input contains character from outside the
| base64 alphabet.
[1] <http://php.net/manual/en/function.base64-decode.php>
------------------------------------------------------------------------
[2016-05-25 18:55:23] lauri dot kentta at gmail dot com
Description:
------------
base64_decode $strict fails with whitespace between padding.
Test script:
---------------
<?php
var_dump(base64_decode("VV= =", true));
Expected result:
----------------
string(1) "U"
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72264&edit=1