diff --git a/lib/api/routes/icon_sets.js b/lib/api/routes/icon_sets.js index 88c0935..6a97b26 100644 --- a/lib/api/routes/icon_sets.js +++ b/lib/api/routes/icon_sets.js @@ -19,8 +19,7 @@ router.get('/:set/:file', asyncWrap(async (req, res) => { let buf; try { buf = await sets.readIcon(req.params.set, req.params.file); } catch (e) { return res.status(e.message === 'bad_slug' ? 400 : 404).end(); } - const ct = req.params.file.endsWith('.svg') ? 'image/svg+xml' - : req.params.file.endsWith('.png') ? 'image/png' : 'image/jpeg'; + const ct = req.params.file.endsWith('.svg') ? 'image/svg+xml' : 'image/png'; res.set('Content-Type', ct).set('Cache-Control', 'public, max-age=86400').send(buf); })); diff --git a/lib/icons/ingest.js b/lib/icons/ingest.js index ff574cb..1db0cb8 100644 --- a/lib/icons/ingest.js +++ b/lib/icons/ingest.js @@ -9,16 +9,14 @@ export const MAX_ZIP_ENTRIES = 200; export const MAX_ZIP_TOTAL = 5 * 1024 * 1024; // 5 MB uncompressed export const MAX_URL_BYTES = 5 * 1024 * 1024; -const EXT = { '.svg': 'image/svg+xml', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg' }; +const EXT = { '.svg': 'image/svg+xml', '.png': 'image/png' }; const PNG_SIG = [0x89,0x50,0x4e,0x47]; -const JPG_SIG = [0xff,0xd8,0xff]; function slugBase(name) { return path.basename(name, path.extname(name)).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, ''); } function magicOk(ext, buf) { if (ext === '.png') return PNG_SIG.every((b, i) => buf[i] === b); - if (ext === '.jpg' || ext === '.jpeg') return JPG_SIG.every((b, i) => buf[i] === b); if (ext === '.svg') return buf.toString('utf8', 0, 400).includes('