From 84dcecf50b501ad477d7d153b41ab176ea9e3727 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 8 May 2023 13:12:16 +0300 Subject: [PATCH] add svg images support, fix mime validation --- crontab/crawler.php | 6 +++++- public/search.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crontab/crawler.php b/crontab/crawler.php index 342144a..e36dc12 100644 --- a/crontab/crawler.php +++ b/crontab/crawler.php @@ -292,6 +292,8 @@ try { if ($hostImageBanned) { $hostImagesBanned += $db->updateHostImageTimeBanned($queueHostImage->hostImageId, time()); + + continue; } // Convert remote image data to base64 string @@ -319,7 +321,7 @@ try { continue; } - $hostImageData = 'data:image/' . $hostImageExtension . ';base64,' . $hostImageBase64; + $hostImageData = 'data:image/' . str_replace(['svg'], ['svg+xml'], $hostImageExtension) . ';base64,' . $hostImageBase64; } else { @@ -380,6 +382,8 @@ try { if ($hostPageBanned) { $hostPagesBanned += $db->updateHostPageTimeBanned($queueHostPage->hostPageId, time()); + + continue; } // Skip page processing without returned data diff --git a/public/search.php b/public/search.php index b558b07..c16aea8 100644 --- a/public/search.php +++ b/public/search.php @@ -382,6 +382,8 @@ if (!empty($q)) { if ($hostImageBanned) { $hostImagesBanned += $db->updateHostImageTimeBanned($hostImage->hostImageId, time()); + + continue; } // Skip image processing without returned content @@ -407,7 +409,7 @@ if (!empty($q)) { continue; } - $hostImageURLencoded = 'data:image/' . $hostImageExtension . ';base64,' . $hostImageBase64; + $hostImageURLencoded = 'data:image/' . str_replace(['svg'], ['svg+xml'], $hostImageExtension) . ';base64,' . $hostImageBase64; // Save image content on data settings enabled $db->updateHostImage($hostImage->hostImageId,