diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-01-20 17:18:17 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-24 22:36:09 +0100 |
commit | c388a879d73633b6ebe8353fd2a0407b908fe26f (patch) | |
tree | 3a09d39c87751105ace98936c8c210c57eee2fe8 /Userland/Applications | |
parent | f590cd1850027399ab7f0193ba97fa76b3a9cbab (diff) | |
download | serenity-c388a879d73633b6ebe8353fd2a0407b908fe26f.zip |
AK+Userland: Make AK::decode_base64 return ErrorOr
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/Mail/MailWidget.cpp | 4 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/Image.cpp | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp index 15c01513f7..e5e6670233 100644 --- a/Userland/Applications/Mail/MailWidget.cpp +++ b/Userland/Applications/Mail/MailWidget.cpp @@ -499,7 +499,9 @@ void MailWidget::selected_email_to_load() if (selected_alternative_encoding.equals_ignoring_case("7bit") || selected_alternative_encoding.equals_ignoring_case("8bit")) { decoded_data = encoded_data; } else if (selected_alternative_encoding.equals_ignoring_case("base64")) { - decoded_data = decode_base64(encoded_data).value_or(ByteBuffer()); + auto decoded_base64 = decode_base64(encoded_data); + if (!decoded_base64.is_error()) + decoded_data = decoded_base64.release_value(); } else if (selected_alternative_encoding.equals_ignoring_case("quoted-printable")) { decoded_data = IMAP::decode_quoted_printable(encoded_data); } else { diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index c16f337d95..b61152a4ae 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -88,11 +88,8 @@ ErrorOr<NonnullRefPtr<Image>> Image::try_create_from_pixel_paint_json(JsonObject auto name = layer_object.get("name").as_string(); auto bitmap_base64_encoded = layer_object.get("bitmap").as_string(); - auto bitmap_data = decode_base64(bitmap_base64_encoded); - if (!bitmap_data.has_value()) - return Error::from_string_literal("Base64 decode failed"sv); - - auto bitmap = TRY(try_decode_bitmap(bitmap_data.value())); + auto bitmap_data = TRY(decode_base64(bitmap_base64_encoded)); + auto bitmap = TRY(try_decode_bitmap(bitmap_data)); auto layer = TRY(Layer::try_create_with_bitmap(*image, move(bitmap), name)); auto width = layer_object.get("width").to_i32(); |