release(v1.9.9): fix(branding): sanitize custom logo URL

This commit is contained in:
Ryan
2025-11-16 21:31:08 -05:00
committed by GitHub
parent ad1d41fad8
commit 08f7ffccbc
2 changed files with 20 additions and 1 deletions

View File

@@ -85,7 +85,15 @@ function updateHeaderLogoFromAdmin() {
url = '/' + url;
}
if (url) {
// ---- Sanitize URL (mirror AdminModel::sanitizeLogoUrl) ----
const isHttp = /^https?:\/\//i.test(url);
const isSiteRelative = url.startsWith('/') && !url.includes('://');
// Strip any CR/LF just in case
url = url.replace(/[\r\n]+/g, '');
if (url && (isHttp || isSiteRelative)) {
// safe enough for <img src="...">
logoImg.setAttribute('src', url);
logoImg.setAttribute('alt', 'Site logo');
} else {