mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 08:11:13 +00:00
AK: Use new simdutf option to add padding to Base64URL encodings
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
60252eca2e
commit
408532c910
Notes:
github-actions[bot]
2024-08-31 05:48:18 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/408532c9102 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1230
|
@ -33,22 +33,14 @@ static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, simdutf::base64_
|
|||
static ErrorOr<String> encode_base64_impl(StringView input, simdutf::base64_options options)
|
||||
{
|
||||
Vector<u8> output;
|
||||
TRY(output.try_resize(simdutf::base64_length_from_binary(input.length(), options)));
|
||||
|
||||
// simdutf does not append padding to base64url encodings. We use the default encoding option here to allocate room
|
||||
// for the padding characters that we will later append ourselves if necessary.
|
||||
TRY(output.try_resize(simdutf::base64_length_from_binary(input.length(), simdutf::base64_default)));
|
||||
|
||||
auto size_written = simdutf::binary_to_base64(
|
||||
simdutf::binary_to_base64(
|
||||
input.characters_without_null_termination(),
|
||||
input.length(),
|
||||
reinterpret_cast<char*>(output.data()),
|
||||
options);
|
||||
|
||||
if (options == simdutf::base64_url) {
|
||||
for (size_t i = size_written; i < output.size(); ++i)
|
||||
output[i] = '=';
|
||||
}
|
||||
|
||||
return String::from_utf8_without_validation(output);
|
||||
}
|
||||
|
||||
|
@ -69,7 +61,7 @@ ErrorOr<String> encode_base64(ReadonlyBytes input)
|
|||
|
||||
ErrorOr<String> encode_base64url(ReadonlyBytes input)
|
||||
{
|
||||
return encode_base64_impl(input, simdutf::base64_url);
|
||||
return encode_base64_impl(input, simdutf::base64_url_with_padding);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue