fix: drop jpg/jpeg support from icon system (svg + png only)
Icons.display path only handles svg/png, so jpg-backed icons never rendered. Remove jpg/jpeg: drop from EXT map and magicOk in ingest.js, narrow FILE regex in sets.js to (svg|png), update the file input accept attribute in icon_sets_panel.js, and simplify the content-type ternary in the icon_sets route (jpeg branch was now unreachable). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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('<svg');
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user