Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilip Skokan <panva.ip@gmail.com>2021-01-15 23:01:28 +0300
committerAntoine du Hamel <duhamelantoine1995@gmail.com>2021-01-18 14:08:20 +0300
commitf8ab632d56ea15c78b1dc5db1624109a2bf7b69b (patch)
tree248839d4a4ed92d3fc8e4b0ca8a770744ab0cc8f /src/string_decoder.cc
parent9e7d1a1c24888ee9f1290579c7170b1eb094d609 (diff)
buffer: add base64url encoding option
PR-URL: https://github.com/nodejs/node/pull/36952 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/string_decoder.cc')
-rw-r--r--src/string_decoder.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/string_decoder.cc b/src/string_decoder.cc
index 0f9e6faaab1..a915f5744f3 100644
--- a/src/string_decoder.cc
+++ b/src/string_decoder.cc
@@ -70,7 +70,10 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
size_t nread = *nread_ptr;
- if (Encoding() == UTF8 || Encoding() == UCS2 || Encoding() == BASE64) {
+ if (Encoding() == UTF8 ||
+ Encoding() == UCS2 ||
+ Encoding() == BASE64 ||
+ Encoding() == BASE64URL) {
// See if we want bytes to finish a character from the previous
// chunk; if so, copy the new bytes to the missing bytes buffer
// and create a small string from it that is to be prepended to the
@@ -198,7 +201,7 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
state_[kBufferedBytes] = 2;
state_[kMissingBytes] = 2;
}
- } else if (Encoding() == BASE64) {
+ } else if (Encoding() == BASE64 || Encoding() == BASE64URL) {
state_[kBufferedBytes] = nread % 3;
if (state_[kBufferedBytes] > 0)
state_[kMissingBytes] = 3 - BufferedBytes();
@@ -311,6 +314,7 @@ void InitializeStringDecoder(Local<Object> target,
ADD_TO_ENCODINGS_ARRAY(ASCII, "ascii");
ADD_TO_ENCODINGS_ARRAY(UTF8, "utf8");
ADD_TO_ENCODINGS_ARRAY(BASE64, "base64");
+ ADD_TO_ENCODINGS_ARRAY(BASE64URL, "base64url");
ADD_TO_ENCODINGS_ARRAY(UCS2, "utf16le");
ADD_TO_ENCODINGS_ARRAY(HEX, "hex");
ADD_TO_ENCODINGS_ARRAY(BUFFER, "buffer");