COMMON: Get rid of global constructor

This commit is contained in:
Eugene Sandulenko 2024-05-18 14:00:17 +02:00
parent 4d07d1b2ad
commit 0a034af1b2
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -28,7 +28,7 @@
namespace Common {
static const String encodingTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char *encodingTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
bool b64Validate(String &string) {
bool paddingStarted = false;
@ -38,9 +38,11 @@ bool b64Validate(String &string) {
if ((strlen(string.c_str()) % 4) > 0)
return false;
String encodingStr(encodingTable);
// It must also use characters defined in the encoding table,
for (char c : string) {
if (!encodingTable.contains(c)) {
if (!encodingStr.contains(c)) {
// or the padding character (=).
if (c != '=')
return false;