Skip to content

Commit

Permalink
LibWeb: Handle TextDecoder's fatal flag
Browse files Browse the repository at this point in the history
  • Loading branch information
skyrising authored and awesomekling committed May 27, 2024
1 parent f8ac883 commit 3029406
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Userland/Libraries/LibWeb/Encoding/TextDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

0 comments on commit 3029406

Please sign in to comment.