diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2017-06-27 10:00:42 -0400 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2017-07-06 16:36:35 -0400 |
commit | 4b222edf455a34667cfaf7b67e7f8dfdca42bd9c (patch) | |
tree | 5f468e532fa02650803ea20036c7b9a9161ce96f /src/mongo/bson | |
parent | f0b95cc0c48fe242edbc9c7958f9df0a34813e78 (diff) | |
download | mongo-4b222edf455a34667cfaf7b67e7f8dfdca42bd9c.tar.gz |
SERVER-15194 Refactor base64::decode Implementation
* Existing check for length as multiple of 4 as-is
* Added check for non-base64 characters on input
* Added check for terminators ('=') midstream
Implicitly in positions 0 and 1 via non-base64 check
Explicitly in positions 2 and 3 via "done" check.
Moved "Alphabet" class into cpp file in anon namespace
as it's an implementation detail and shouldn't be used
by outside classes.
Added base64::validate() method to accomodate BSON's
isBase64String() check.
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/json.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/mongo/bson/json.cpp b/src/mongo/bson/json.cpp index d6a94ea08eb..647accf31ba 100644 --- a/src/mongo/bson/json.cpp +++ b/src/mongo/bson/json.cpp @@ -1280,13 +1280,7 @@ bool JParse::isHexString(StringData str) const { bool JParse::isBase64String(StringData str) const { MONGO_JSON_DEBUG("str: " << str); - std::size_t i; - for (i = 0; i < str.size(); i++) { - if (!match(str[i], base64::chars)) { - return false; - } - } - return true; + return base64::validate(str); } bool JParse::isArray() { |