1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Don't return icons without types at all

This commit is contained in:
J. King 2021-01-27 13:41:10 -05:00
parent cd5f13f4b9
commit ad094f5217
2 changed files with 5 additions and 5 deletions

View file

@ -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'],
]);
}

View file

@ -741,8 +741,8 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
self::clearData();
return [
[['id' => 44, 'type' => "image/svg+xml", 'data' => "<svg/>"], new Response(['id' => 44, 'data' => "image/svg+xml;base64,PHN2Zy8+", 'mime_type' => "image/svg+xml"])],
[['id' => 47, 'type' => "", 'data' => "<svg/>"], new Response(['id' => 47, 'data' => "application/octet-stream;base64,PHN2Zy8+", 'mime_type' => "application/octet-stream"])],
[['id' => 47, 'type' => null, 'data' => "<svg/>"], new Response(['id' => 47, 'data' => "application/octet-stream;base64,PHN2Zy8+", 'mime_type' => "application/octet-stream"])],
[['id' => 47, 'type' => "", 'data' => "<svg/>"], new ErrorResponse("404", 404)],
[['id' => 47, 'type' => null, 'data' => "<svg/>"], 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)],