fix(branding): accept SVG favicons
The favicon upload allowed only PNG/ICO, so an SVG favicon was rejected. Accept image/svg+xml (.svg) too - DynamicFavicon already emits the right MIME type and served SVGs are CSP-locked (render-only) by secureStatic. Update the EN/DE help text accordingly.
This commit is contained in:
@@ -76,6 +76,7 @@ const faviconUpload = multer({
|
|||||||
limits: { fileSize: 2 * 1024 * 1024 }, // 2MB — roomy enough for a 512×512+ square PNG
|
limits: { fileSize: 2 * 1024 * 1024 }, // 2MB — roomy enough for a 512×512+ square PNG
|
||||||
fileFilter: (req, file, cb) => {
|
fileFilter: (req, file, cb) => {
|
||||||
const allowedMimeTypes = ['image/png', 'image/x-icon', 'image/vnd.microsoft.icon'];
|
const allowedMimeTypes = ['image/png', 'image/x-icon', 'image/vnd.microsoft.icon'];
|
||||||
|
const name = file.originalname.toLowerCase();
|
||||||
|
|
||||||
// For ICO files, we can't use the standard validateFileType
|
// For ICO files, we can't use the standard validateFileType
|
||||||
if (file.mimetype === 'image/png') {
|
if (file.mimetype === 'image/png') {
|
||||||
@@ -84,12 +85,16 @@ const faviconUpload = multer({
|
|||||||
} else {
|
} else {
|
||||||
cb(new Error('Invalid PNG file'));
|
cb(new Error('Invalid PNG file'));
|
||||||
}
|
}
|
||||||
|
} else if (file.mimetype === 'image/svg+xml' && name.endsWith('.svg')) {
|
||||||
|
// SVG favicons are supported by modern browsers and are crisp at any
|
||||||
|
// size. Served SVGs are CSP-locked (no script execution) by the
|
||||||
|
// secureStatic middleware, so an admin-uploaded SVG is render-only.
|
||||||
|
cb(null, true);
|
||||||
} else if (allowedMimeTypes.includes(file.mimetype) &&
|
} else if (allowedMimeTypes.includes(file.mimetype) &&
|
||||||
(file.originalname.toLowerCase().endsWith('.ico') ||
|
(name.endsWith('.ico') || name.endsWith('.png'))) {
|
||||||
file.originalname.toLowerCase().endsWith('.png'))) {
|
|
||||||
cb(null, true);
|
cb(null, true);
|
||||||
} else {
|
} else {
|
||||||
cb(new Error('Favicon must be PNG or ICO format'));
|
cb(new Error('Favicon must be PNG, ICO, or SVG format'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1708,7 +1708,7 @@
|
|||||||
"currentFavicon": "Aktuelles Favicon",
|
"currentFavicon": "Aktuelles Favicon",
|
||||||
"uploadFavicon": "Favicon hochladen",
|
"uploadFavicon": "Favicon hochladen",
|
||||||
"removeFavicon": "Favicon entfernen",
|
"removeFavicon": "Favicon entfernen",
|
||||||
"faviconHelp": "PNG- oder ICO-Format. Bitte ein quadratisches Bild verwenden – empfohlen sind 512×512px für eine scharfe Darstellung auf hochauflösenden Bildschirmen; kleinere Größen funktionieren ebenfalls.",
|
"faviconHelp": "PNG-, ICO- oder SVG-Format. Bitte ein quadratisches Bild verwenden – ein SVG (oder ein 512×512px-PNG) liefert die schärfste Darstellung auf hochauflösenden Bildschirmen; kleinere Größen funktionieren ebenfalls.",
|
||||||
"watermarkSettings": "Wasserzeichen-Einstellungen",
|
"watermarkSettings": "Wasserzeichen-Einstellungen",
|
||||||
"enableWatermarks": "Wasserzeichen aktivieren",
|
"enableWatermarks": "Wasserzeichen aktivieren",
|
||||||
"watermarkHelp": "Fügen Sie Ihren Firmennamen als Wasserzeichen auf heruntergeladenen Fotos hinzu",
|
"watermarkHelp": "Fügen Sie Ihren Firmennamen als Wasserzeichen auf heruntergeladenen Fotos hinzu",
|
||||||
|
|||||||
@@ -1297,7 +1297,7 @@
|
|||||||
"currentFavicon": "Current favicon",
|
"currentFavicon": "Current favicon",
|
||||||
"uploadFavicon": "Upload Favicon",
|
"uploadFavicon": "Upload Favicon",
|
||||||
"removeFavicon": "Remove Favicon",
|
"removeFavicon": "Remove Favicon",
|
||||||
"faviconHelp": "PNG or ICO format. Use a square image — 512×512px is recommended for crisp display on high-resolution screens; smaller sizes work too.",
|
"faviconHelp": "PNG, ICO, or SVG format. Use a square image — an SVG (or a 512×512px PNG) gives the crispest display on high-resolution screens; smaller sizes work too.",
|
||||||
"watermarkSettings": "Watermark Settings",
|
"watermarkSettings": "Watermark Settings",
|
||||||
"enableWatermarks": "Enable Watermarks",
|
"enableWatermarks": "Enable Watermarks",
|
||||||
"watermarkHelp": "Add your company name as a watermark on downloaded photos",
|
"watermarkHelp": "Add your company name as a watermark on downloaded photos",
|
||||||
|
|||||||
Reference in New Issue
Block a user