|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-26 21:53 UTC] iliaa@php.net
-Assigned To:
+Assigned To: iliaa
[2010-11-26 21:59 UTC] iliaa@php.net
[2010-11-26 21:59 UTC] iliaa@php.net
-Status: Assigned
+Status: Closed
[2010-11-26 21:59 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Description: ------------ According to the MIME standard that we're following, this isn't supposed to work when strict mode is enabled. Equal-signs are strictly reserved for padding characters at the _end_ of a base64 MIME string. Leading '=' signs are allowed in each block of 4 bytes because the condition that checks for invalid placement of the '=' signs only checks if (i % 4) == 1, Whereas it should check if (i % 4) is 0 or 1. You should be able to change the circumstances for a valid '=' placement, as follows, to conform to the standard: // to see if bit position 2 is set (for all values of i = n*4+2 and i = n*4+3) if (i & 2) // means that the '=' is in a valid location I would also suggest *carefully* looking over the block at the end of the base64_decode() function... as it seems that if (ch == base64_pad) after ch is ALWAYS set to '\0' is an impossible scenario. Test script: --------------- <?php echo base64_decode('=VGhl=ICc9=JyBz=eW1i=b2xz=IGFy=ZW4n=dCBh=bGxv=d2Vk=IHdo=ZXJl=IGkg=cHV0=IHRo=ZW0g=by5P'); ?> Expected result: ---------------- should return FALSE/NULL/Errornous value Actual result: -------------- echos: The '=' symbols aren't allowed where i put them o.O