fix: allow any image source but disallow base64

This commit is contained in:
Elias Schneider
2025-10-03 11:50:39 +02:00
parent 507f9490fa
commit 22f4254932
4 changed files with 4 additions and 16 deletions

View File

@@ -34,7 +34,7 @@ func (m *CspMiddleware) Add() gin.HandlerFunc {
"object-src 'none'; " + "object-src 'none'; " +
"frame-ancestors 'none'; " + "frame-ancestors 'none'; " +
"form-action 'self'; " + "form-action 'self'; " +
"img-src 'self' data: blob:; " + "img-src * blob:;" +
"font-src 'self'; " + "font-src 'self'; " +
"style-src 'self' 'unsafe-inline'; " + "style-src 'self' 'unsafe-inline'; " +
"script-src 'self' 'nonce-" + nonce + "'" "script-src 'self' 'nonce-" + nonce + "'"

View File

@@ -35,12 +35,7 @@
isLoading = true; isLoading = true;
const reader = new FileReader(); imageDataURL = URL.createObjectURL(file);
reader.onload = (event) => {
imageDataURL = event.target?.result as string;
};
reader.readAsDataURL(file);
await updateCallback(file).catch(() => { await updateCallback(file).catch(() => {
imageDataURL = cachedProfilePicture.getUrl(userId); imageDataURL = cachedProfilePicture.getUrl(userId);
}); });

View File

@@ -31,12 +31,7 @@
if (!file) return; if (!file) return;
image = file; image = file;
imageDataURL = URL.createObjectURL(file);
const reader = new FileReader();
reader.onload = (event) => {
imageDataURL = event.target?.result as string;
};
reader.readAsDataURL(file);
} }
</script> </script>

View File

@@ -115,9 +115,7 @@
} else { } else {
logo = input; logo = input;
$inputs.logoUrl && ($inputs.logoUrl.value = ''); $inputs.logoUrl && ($inputs.logoUrl.value = '');
const reader = new FileReader(); logoDataURL = URL.createObjectURL(input);
reader.onload = (event) => (logoDataURL = event.target?.result as string);
reader.readAsDataURL(input);
} }
} }