From bda2f4e4860b4e50854bd87a97e8bfba138240e6 Mon Sep 17 00:00:00 2001 From: zsgsdesign Date: Sun, 5 Dec 2021 18:49:18 +0800 Subject: [PATCH] add compatibility to unavailable images caching --- Crawler.php | 3 +++ babel.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Crawler.php b/Crawler.php index 5ce7760..2134af5 100644 --- a/Crawler.php +++ b/Crawler.php @@ -234,6 +234,9 @@ private function cacheImage($dom) $imageResponse = $this->getCodeForcesResponse($url); $extensions = ['image/jpeg' => '.jpg', 'image/png' => '.png', 'image/gif' => '.gif', 'image/bmp' => '.bmp']; if (isset($imageResponse->headers['content-type'])) { + if(!isset($extensions[$imageResponse->headers['content-type']])) { + continue; // image illegal + } $extension = $extensions[$imageResponse->headers['content-type']]; } else { $extension = pathinfo($imageElement->src, PATHINFO_EXTENSION); diff --git a/babel.json b/babel.json index c1d497c..09e9cfd 100644 --- a/babel.json +++ b/babel.json @@ -6,7 +6,7 @@ "description": "CodeForces Gym Interface for NOJ", "license": "MIT", "repository": "https://github.com/NJUPTAAA/NOJ_Extension_CodeForces_Gym", - "version": "0.1.5", + "version": "0.1.6", "website": "https://codeforces.com/gyms", "custom": { "css": "resources/custom.css"