add img-src blob: to CSP, stop refetching blob
This commit is contained in:
1 parent
83c2df4390
commit
9839d48ca0
4 files changed
+8
-16
No files matched your search
@@ -27,7 +27,6 @@ import { getMonitorTypeLabel } from "@/Types/StatusPage";
|
|||||||
import { timezoneOptions } from "@/Utils/timezoneOptions";
|
import { timezoneOptions } from "@/Utils/timezoneOptions";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import { mutate } from "swr";
|
import { mutate } from "swr";
|
||||||
import axios from "axios";
|
|
||||||
import { HeaderConfigStatusControls } from "./Components/HeaderConfigStatusControls";
|
import { HeaderConfigStatusControls } from "./Components/HeaderConfigStatusControls";
|
||||||
import { ThemePicker } from "./Components/ThemePicker";
|
import { ThemePicker } from "./Components/ThemePicker";
|
||||||
import { FormSwitchField } from "@/Components/inputs/forms/FormSwitchField";
|
import { FormSwitchField } from "@/Components/inputs/forms/FormSwitchField";
|
||||||
@@ -59,7 +58,9 @@ const LogoUploadField = () => {
|
|||||||
<ImageUpload
|
<ImageUpload
|
||||||
src={field.value?.data}
|
src={field.value?.data}
|
||||||
onChange={(file) => {
|
onChange={(file) => {
|
||||||
field.onChange(file ? { data: file.src, contentType: file.file.type } : null);
|
field.onChange(
|
||||||
|
file ? { data: file.src, contentType: file.file.type, file: file.file } : null
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -204,18 +205,8 @@ const CreateStatusPage = () => {
|
|||||||
if (data.logo === null) {
|
if (data.logo === null) {
|
||||||
// Signal to remove the logo
|
// Signal to remove the logo
|
||||||
fd.append("removeLogo", "true");
|
fd.append("removeLogo", "true");
|
||||||
} else if (data.logo?.data && data.logo.data !== "") {
|
} else if (data.logo?.file) {
|
||||||
if (data.logo.data.startsWith("blob:")) {
|
fd.append("logo", data.logo.file);
|
||||||
try {
|
|
||||||
const imageResult = await axios.get(data.logo.data, {
|
|
||||||
responseType: "blob",
|
|
||||||
});
|
|
||||||
fd.append("logo", imageResult.data);
|
|
||||||
URL.revokeObjectURL(data.logo.data);
|
|
||||||
} catch (e) {
|
|
||||||
logger.error("Failed to fetch logo blob", e instanceof Error ? e : undefined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export const statusPageSchema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
data: z.string(),
|
data: z.string(),
|
||||||
contentType: z.string(),
|
contentType: z.string(),
|
||||||
|
file: z.instanceof(File).optional(),
|
||||||
})
|
})
|
||||||
.nullable()
|
.nullable()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const PUBLIC_STATUS_PAGE_DOCUMENT_PREFIX = "/status/public";
|
|||||||
// the status page on top of the global helmet policy, blocking external images,
|
// the status page on top of the global helmet policy, blocking external images,
|
||||||
// fonts, and stylesheets from custom CSS while keeping the app's Google Fonts.
|
// fonts, and stylesheets from custom CSS while keeping the app's Google Fonts.
|
||||||
const STATUS_PAGE_CSP = [
|
const STATUS_PAGE_CSP = [
|
||||||
"img-src 'self' data:",
|
"img-src 'self' data: blob:",
|
||||||
"font-src 'self' data: https://fonts.gstatic.com",
|
"font-src 'self' data: https://fonts.gstatic.com",
|
||||||
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
|
||||||
].join("; ");
|
].join("; ");
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ export const createApp = ({
|
|||||||
directives: {
|
directives: {
|
||||||
upgradeInsecureRequests: null,
|
upgradeInsecureRequests: null,
|
||||||
"script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'"],
|
"script-src": ["'self'", "'unsafe-inline'", "'unsafe-eval'"],
|
||||||
"img-src": ["'self'", "data:", "https://img.shields.io"],
|
"img-src": ["'self'", "data:", "blob:", "https://img.shields.io"],
|
||||||
"object-src": ["'none'"],
|
"object-src": ["'none'"],
|
||||||
"base-uri": ["'self'"],
|
"base-uri": ["'self'"],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user