From ad094f5217d9f346ade0f1ece2871dfcb8c69a1a Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 27 Jan 2021 13:41:10 -0500 Subject: [PATCH] Don't return icons without types at all --- lib/REST/Miniflux/V1.php | 6 +++--- tests/cases/REST/Miniflux/TestV1.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/REST/Miniflux/V1.php b/lib/REST/Miniflux/V1.php index 9519865..efd0469 100644 --- a/lib/REST/Miniflux/V1.php +++ b/lib/REST/Miniflux/V1.php @@ -814,13 +814,13 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { } catch (ExceptionInput $e) { return new ErrorResponse("404", 404); } - if (!$icon || !$icon['data']) { + if (!$icon || !$icon['type'] || !$icon['data']) { return new ErrorResponse("404", 404); } return new Response([ 'id' => $icon['id'], - 'data' => ($icon['type'] ?: "application/octet-stream").";base64,".base64_encode($icon['data']), - 'mime_type' => ($icon['type'] ?: "application/octet-stream"), + 'data' => $icon['type'].";base64,".base64_encode($icon['data']), + 'mime_type' => $icon['type'], ]); } diff --git a/tests/cases/REST/Miniflux/TestV1.php b/tests/cases/REST/Miniflux/TestV1.php index 8e6d13d..d04f45a 100644 --- a/tests/cases/REST/Miniflux/TestV1.php +++ b/tests/cases/REST/Miniflux/TestV1.php @@ -741,8 +741,8 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { self::clearData(); return [ [['id' => 44, 'type' => "image/svg+xml", 'data' => ""], new Response(['id' => 44, 'data' => "image/svg+xml;base64,PHN2Zy8+", 'mime_type' => "image/svg+xml"])], - [['id' => 47, 'type' => "", 'data' => ""], new Response(['id' => 47, 'data' => "application/octet-stream;base64,PHN2Zy8+", 'mime_type' => "application/octet-stream"])], - [['id' => 47, 'type' => null, 'data' => ""], new Response(['id' => 47, 'data' => "application/octet-stream;base64,PHN2Zy8+", 'mime_type' => "application/octet-stream"])], + [['id' => 47, 'type' => "", 'data' => ""], new ErrorResponse("404", 404)], + [['id' => 47, 'type' => null, 'data' => ""], new ErrorResponse("404", 404)], [['id' => 47, 'type' => null, 'data' => null], new ErrorResponse("404", 404)], [null, new ErrorResponse("404", 404)], [new ExceptionInput("subjectMissing"), new ErrorResponse("404", 404)],