mirror of https://github.com/VERT-sh/VERT.git
fix: strange xss vulnerability in theme cookie
This commit is contained in:
parent
2880d9bf8c
commit
592bd1c1d9
|
@ -1,7 +1,14 @@
|
|||
import type { Handle } from "@sveltejs/kit";
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
const theme = event.cookies.get("theme") ?? "";
|
||||
let theme = event.cookies.get("theme") ?? "";
|
||||
if (theme !== "dark" && theme !== "light") {
|
||||
event.cookies.set("theme", "", {
|
||||
path: "/",
|
||||
sameSite: "strict",
|
||||
});
|
||||
theme = "";
|
||||
}
|
||||
const res = await resolve(event, {
|
||||
transformPageChunk: ({ html }) => html.replace("%theme%", theme),
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue