mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 04:27:12 +02:00
LibWeb: Handle TextDecoder's fatal flag
This commit is contained in:
committed by
Andreas Kling
parent
f8ac883fb4
commit
3029406c4b
Notes:
sideshowbarker
2024-07-17 18:08:55 +09:00
Author: https://github.com/skyrising Commit: https://github.com/SerenityOS/serenity/commit/3029406c4b Pull-request: https://github.com/SerenityOS/serenity/pull/24463
@@ -56,7 +56,10 @@ WebIDL::ExceptionOr<String> TextDecoder::decode(Optional<JS::Handle<WebIDL::Buff
|
||||
if (data_buffer_or_error.is_error())
|
||||
return WebIDL::OperationError::create(realm(), "Failed to copy bytes from ArrayBuffer"_fly_string);
|
||||
auto& data_buffer = data_buffer_or_error.value();
|
||||
return TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({ data_buffer.data(), data_buffer.size() }));
|
||||
auto result = TRY_OR_THROW_OOM(vm(), m_decoder.to_utf8({ data_buffer.data(), data_buffer.size() }));
|
||||
if (this->fatal() && result.contains(0xfffd))
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Decoding failed"sv };
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user