From 345ad17224172c65089d9a583d2adafa050d33c9 Mon Sep 17 00:00:00 2001 From: maxitect Date: Thu, 12 Nov 2026 23:16:30 +0000 Subject: [PATCH 1/5] fix(security): accept only https links and known embed hosts from the CMS --- .../(frontend)/music/_components/Bandcamp.tsx | 8 ++++-- .../(frontend)/music/_components/Spotify.tsx | 6 +++- .../(frontend)/music/_components/Youtube.tsx | 6 +++- .../(frontend)/tour/_components/TourDate.tsx | 5 +++- src/lib/payload/validators.ts | 22 ++------------- src/utils/safeUrl.ts | 28 +++++++++++++++++++ 6 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 src/utils/safeUrl.ts diff --git a/src/app/(frontend)/music/_components/Bandcamp.tsx b/src/app/(frontend)/music/_components/Bandcamp.tsx index a8a682b..cdbe7cb 100644 --- a/src/app/(frontend)/music/_components/Bandcamp.tsx +++ b/src/app/(frontend)/music/_components/Bandcamp.tsx @@ -1,16 +1,20 @@ import { IFrameProps } from "@/utils/types"; +import { safeEmbedSrc, safeHttpsUrl } from "@/utils/safeUrl"; export default function Bandcamp({ src, href, title }: IFrameProps) { + const safeSrc = safeEmbedSrc(src, "bandcamp"); + if (!safeSrc) return null; + return ( ); } diff --git a/src/app/(frontend)/music/_components/Spotify.tsx b/src/app/(frontend)/music/_components/Spotify.tsx index f370283..f7be6fe 100644 --- a/src/app/(frontend)/music/_components/Spotify.tsx +++ b/src/app/(frontend)/music/_components/Spotify.tsx @@ -1,10 +1,14 @@ import { IFrameProps } from "@/utils/types"; +import { safeEmbedSrc } from "@/utils/safeUrl"; export default function Spotify({ src, title }: IFrameProps) { + const safeSrc = safeEmbedSrc(src, "spotify"); + if (!safeSrc) return null; + return (