mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Add a public helper to count the decoded length of a Base64 string
This commit is contained in:
parent
41e14e3fc3
commit
35d8e7e63f
Notes:
github-actions[bot]
2024-09-03 15:47:24 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/35d8e7e63f9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1258 Reviewed-by: https://github.com/awesomekling
2 changed files with 8 additions and 1 deletions
|
@ -12,10 +12,15 @@
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
|
size_t size_required_to_decode_base64(StringView input)
|
||||||
|
{
|
||||||
|
return simdutf::maximal_binary_length_from_base64(input.characters_without_null_termination(), input.length());
|
||||||
|
}
|
||||||
|
|
||||||
static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, simdutf::base64_options options)
|
static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, simdutf::base64_options options)
|
||||||
{
|
{
|
||||||
ByteBuffer output;
|
ByteBuffer output;
|
||||||
TRY(output.try_resize(simdutf::maximal_binary_length_from_base64(input.characters_without_null_termination(), input.length())));
|
TRY(output.try_resize(size_required_to_decode_base64(input)));
|
||||||
|
|
||||||
auto result = simdutf::base64_to_binary(
|
auto result = simdutf::base64_to_binary(
|
||||||
input.characters_without_null_termination(),
|
input.characters_without_null_termination(),
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
|
size_t size_required_to_decode_base64(StringView);
|
||||||
|
|
||||||
ErrorOr<ByteBuffer> decode_base64(StringView);
|
ErrorOr<ByteBuffer> decode_base64(StringView);
|
||||||
ErrorOr<ByteBuffer> decode_base64url(StringView);
|
ErrorOr<ByteBuffer> decode_base64url(StringView);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue