mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 08:11:13 +00:00
LibWeb: Add response status check in SharedImageRequest::fetch_image
If an image response status was not ok, we would still pass the received body data to ImageDecoder which is not correct.
This commit is contained in:
parent
d176ed30df
commit
8085e3eb26
Notes:
sideshowbarker
2024-07-17 10:54:57 +09:00
Author: https://github.com/rmg-x Commit: https://github.com/LadybirdBrowser/ladybird/commit/8085e3eb26 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/464 Reviewed-by: https://github.com/ADKaster ✅
|
@ -10,6 +10,7 @@
|
|||
#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Statuses.h>
|
||||
#include <LibWeb/HTML/AnimatedBitmapDecodedImageData.h>
|
||||
#include <LibWeb/HTML/DecodedImageData.h>
|
||||
#include <LibWeb/HTML/SharedImageRequest.h>
|
||||
|
@ -94,10 +95,13 @@ void SharedImageRequest::fetch_image(JS::Realm& realm, JS::NonnullGCPtr<Fetch::I
|
|||
handle_failed_fetch();
|
||||
});
|
||||
|
||||
if (response->body())
|
||||
response->body()->fully_read(realm, process_body, process_body_error, JS::NonnullGCPtr { realm.global_object() });
|
||||
else
|
||||
// Check for failed fetch response
|
||||
if (!Fetch::Infrastructure::is_ok_status(response->status()) || !response->body()) {
|
||||
handle_failed_fetch();
|
||||
return;
|
||||
}
|
||||
|
||||
response->body()->fully_read(realm, process_body, process_body_error, JS::NonnullGCPtr { realm.global_object() });
|
||||
};
|
||||
|
||||
m_state = State::Fetching;
|
||||
|
|
Loading…
Reference in a new issue