LibWeb: Add response status check when loading fallback favicon

If a favicon image response status was not ok,
we would still attempt to decode the received body data.
This commit is contained in:
rmg-x 2024-07-06 14:42:57 -05:00 committed by Andrew Kaster
parent 8085e3eb26
commit 7f04ceb4f6
Notes: sideshowbarker 2024-07-17 05:01:20 +09:00

View file

@ -584,6 +584,11 @@ WebIDL::ExceptionOr<void> HTMLLinkElement::load_fallback_favicon_if_needed(JS::N
auto process_body_error = JS::create_heap_function(realm.heap(), [](JS::Value) {
});
// Check for failed favicon response
if (!Fetch::Infrastructure::is_ok_status(response->status()) || !response->body()) {
return;
}
// 3. Use response's unsafe response as an icon as if it had been declared using the icon keyword.
if (auto body = response->unsafe_response()->body())
body->fully_read(realm, process_body, process_body_error, global);