From 223494c548496a6201eff52479d70058cfb5f5c9 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 15 Jan 2021 21:01:28 +0100 Subject: [PATCH] buffer: add base64url encoding option Backport parts of https://github.com/nodejs/node/commit/dae283d96fd31ad0f30840a7e55ac97294f505ac PR-URL: https://github.com/nodejs/node/pull/36952 Backport-PR-URL: https://github.com/nodejs/node/pull/39702 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen --- doc/api/buffer.md | 16 +- lib/buffer.js | 19 ++ lib/internal/buffer.js | 4 + lib/internal/util.js | 5 + src/api/encoding.cc | 4 + src/base64-inl.h | 20 +- src/base64.h | 34 +- src/node.h | 13 +- src/node_buffer.cc | 2 + src/string_bytes.cc | 20 ++ src/string_decoder.cc | 8 +- test/addons/parse-encoding/binding.cc | 1 + test/addons/parse-encoding/test.js | 1 + test/cctest/test_base64.cc | 15 + test/parallel/test-buffer-alloc.js | 304 ++++++++++++------ test/parallel/test-buffer-bytelength.js | 10 + test/parallel/test-buffer-fill.js | 44 ++- test/parallel/test-buffer-isencoding.js | 1 + test/parallel/test-buffer-write.js | 3 +- .../test-internal-util-normalizeencoding.js | 3 + test/parallel/test-string-decoder-end.js | 9 +- test/parallel/test-string-decoder-fuzz.js | 2 +- 22 files changed, 399 insertions(+), 139 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index c1423229ca6a34..76c920f0b661d4 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -50,6 +50,9 @@ const buf7 = Buffer.from('tést', 'latin1'); ## Buffers and character encodings