1--TEST--
2Test base64_decode() function : basic functionality - padding and whitespace
3--FILE--
4<?php
5echo "Test base64_decode (output as JSON):\n";
6$data = [
7    "", "=", "==", "===", "====",
8    "V", "V=", "V==", "V===", "V====",
9    "VV", "VV=", "VV==", "VV===", "VV====",
10    "VVV", "VVV=", "VVV==", "VVV===", "VVV====",
11    "VVVV", "VVVV=", "VVVV==", "VVVV===", "VVVV====",
12    "=V", "=VV", "=VVV",
13    "==V", "==VV", "==VVV",
14    "===V", "===VV", "===VVV",
15    "====V", "====VV", "====VVV",
16    "=VVV", "V=VV", "VV=V", "VVV=",
17    "=VVVV", "V=VVV", "VV=VV", "VVV=V", "VVVV=",
18    "=VVV=", "V=VV=", "VV=V=", "VVV==",
19    "\nVV", "V\nV", "VV\n",
20    "\nVV==", "V\nV==", "VV\n==", "VV=\n=", "VV==\n",
21    "*VV", "V*V", "VV*",
22    "*VV==", "V*V==", "VV*==", "VV=*=", "VV==*",
23    "\0VV==", "V\0V==", "VV\0==", "VV=\0=", "VV==\0",
24    "\0VVV==", "V\0VV==", "VV\0V==", "VVV\0==", "VVV=\0=", "VVV==\0",
25];
26foreach ($data as $a) {
27    $b = base64_decode($a, false);
28    $c = base64_decode($a, true);
29    printf("base64 %-16s non-strict %-8s strict %s\n", json_encode($a), json_encode($b), json_encode($c));
30}
31echo "Done\n";
32?>
33--EXPECT--
34Test base64_decode (output as JSON):
35base64 ""               non-strict ""       strict ""
36base64 "="              non-strict ""       strict false
37base64 "=="             non-strict ""       strict false
38base64 "==="            non-strict ""       strict false
39base64 "===="           non-strict ""       strict false
40base64 "V"              non-strict ""       strict false
41base64 "V="             non-strict ""       strict false
42base64 "V=="            non-strict ""       strict false
43base64 "V==="           non-strict ""       strict false
44base64 "V===="          non-strict ""       strict false
45base64 "VV"             non-strict "U"      strict "U"
46base64 "VV="            non-strict "U"      strict false
47base64 "VV=="           non-strict "U"      strict "U"
48base64 "VV==="          non-strict "U"      strict false
49base64 "VV===="         non-strict "U"      strict false
50base64 "VVV"            non-strict "UU"     strict "UU"
51base64 "VVV="           non-strict "UU"     strict "UU"
52base64 "VVV=="          non-strict "UU"     strict false
53base64 "VVV==="         non-strict "UU"     strict false
54base64 "VVV===="        non-strict "UU"     strict false
55base64 "VVVV"           non-strict "UUU"    strict "UUU"
56base64 "VVVV="          non-strict "UUU"    strict false
57base64 "VVVV=="         non-strict "UUU"    strict false
58base64 "VVVV==="        non-strict "UUU"    strict false
59base64 "VVVV===="       non-strict "UUU"    strict false
60base64 "=V"             non-strict ""       strict false
61base64 "=VV"            non-strict "U"      strict false
62base64 "=VVV"           non-strict "UU"     strict false
63base64 "==V"            non-strict ""       strict false
64base64 "==VV"           non-strict "U"      strict false
65base64 "==VVV"          non-strict "UU"     strict false
66base64 "===V"           non-strict ""       strict false
67base64 "===VV"          non-strict "U"      strict false
68base64 "===VVV"         non-strict "UU"     strict false
69base64 "====V"          non-strict ""       strict false
70base64 "====VV"         non-strict "U"      strict false
71base64 "====VVV"        non-strict "UU"     strict false
72base64 "=VVV"           non-strict "UU"     strict false
73base64 "V=VV"           non-strict "UU"     strict false
74base64 "VV=V"           non-strict "UU"     strict false
75base64 "VVV="           non-strict "UU"     strict "UU"
76base64 "=VVVV"          non-strict "UUU"    strict false
77base64 "V=VVV"          non-strict "UUU"    strict false
78base64 "VV=VV"          non-strict "UUU"    strict false
79base64 "VVV=V"          non-strict "UUU"    strict false
80base64 "VVVV="          non-strict "UUU"    strict false
81base64 "=VVV="          non-strict "UU"     strict false
82base64 "V=VV="          non-strict "UU"     strict false
83base64 "VV=V="          non-strict "UU"     strict false
84base64 "VVV=="          non-strict "UU"     strict false
85base64 "\nVV"           non-strict "U"      strict "U"
86base64 "V\nV"           non-strict "U"      strict "U"
87base64 "VV\n"           non-strict "U"      strict "U"
88base64 "\nVV=="         non-strict "U"      strict "U"
89base64 "V\nV=="         non-strict "U"      strict "U"
90base64 "VV\n=="         non-strict "U"      strict "U"
91base64 "VV=\n="         non-strict "U"      strict "U"
92base64 "VV==\n"         non-strict "U"      strict "U"
93base64 "*VV"            non-strict "U"      strict false
94base64 "V*V"            non-strict "U"      strict false
95base64 "VV*"            non-strict "U"      strict false
96base64 "*VV=="          non-strict "U"      strict false
97base64 "V*V=="          non-strict "U"      strict false
98base64 "VV*=="          non-strict "U"      strict false
99base64 "VV=*="          non-strict "U"      strict false
100base64 "VV==*"          non-strict "U"      strict false
101base64 "\u0000VV=="     non-strict "U"      strict false
102base64 "V\u0000V=="     non-strict "U"      strict false
103base64 "VV\u0000=="     non-strict "U"      strict false
104base64 "VV=\u0000="     non-strict "U"      strict false
105base64 "VV==\u0000"     non-strict "U"      strict false
106base64 "\u0000VVV=="    non-strict "UU"     strict false
107base64 "V\u0000VV=="    non-strict "UU"     strict false
108base64 "VV\u0000V=="    non-strict "UU"     strict false
109base64 "VVV\u0000=="    non-strict "UU"     strict false
110base64 "VVV=\u0000="    non-strict "UU"     strict false
111base64 "VVV==\u0000"    non-strict "UU"     strict false
112Done
113