diff options
-rw-r--r-- | Source/WTF/wtf/text/Base64.cpp | 10 | ||||
-rw-r--r-- | Source/WTF/wtf/text/Base64.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Source/WTF/wtf/text/Base64.cpp b/Source/WTF/wtf/text/Base64.cpp index 7a0467a36..5df356165 100644 --- a/Source/WTF/wtf/text/Base64.cpp +++ b/Source/WTF/wtf/text/Base64.cpp @@ -122,9 +122,13 @@ void base64Encode(const char* data, unsigned len, Vector<char>& out, Base64Encod } // Add padding - while (didx < out.size()) { - out[didx] = '='; - ++didx; + if (policy == Base64URLPolicy) + out.resize(didx); + else { + while (didx < out.size()) { + out[didx] = '='; + ++didx; + } } } diff --git a/Source/WTF/wtf/text/Base64.h b/Source/WTF/wtf/text/Base64.h index 5b0d4d80e..1454c72f2 100644 --- a/Source/WTF/wtf/text/Base64.h +++ b/Source/WTF/wtf/text/Base64.h @@ -35,7 +35,8 @@ namespace WTF { enum Base64EncodePolicy { Base64DoNotInsertLFs, - Base64InsertLFs + Base64InsertLFs, + Base64URLPolicy // No padding, no LFs. }; enum Base64DecodePolicy { |