1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

AK+Userland: Make AK::decode_base64 return ErrorOr

This commit is contained in:
Sam Atkins 2022-01-20 17:18:17 +00:00 committed by Andreas Kling
parent f590cd1850
commit c388a879d7
11 changed files with 31 additions and 43 deletions

View file

@ -340,7 +340,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::atob)
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::BadArgCountOne, "atob");
auto string = TRY(vm.argument(0).to_string(global_object));
auto decoded = decode_base64(StringView(string));
if (!decoded.has_value())
if (decoded.is_error())
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::InvalidFormat, "Base64");
// decode_base64() returns a byte string. LibJS uses UTF-8 for strings. Use Latin1Decoder to convert bytes 128-255 to UTF-8.