diff --git a/src/components/Header/HeaderLogo.tsx b/src/components/Header/HeaderLogo.tsx index 7825014c4..509602a8c 100644 --- a/src/components/Header/HeaderLogo.tsx +++ b/src/components/Header/HeaderLogo.tsx @@ -102,11 +102,11 @@ function LogoFallback(props: HeaderLogoProps) { } : { light: { - src: absoluteHref('~gitbook/icon?size=medium&theme=light'), + src: absoluteHref('~gitbook/icon?size=medium&theme=light', true), size: { width: 256, height: 256 }, }, dark: { - src: absoluteHref('~gitbook/icon?size=medium&theme=dark'), + src: absoluteHref('~gitbook/icon?size=medium&theme=dark', true), size: { width: 256, height: 256 }, }, } diff --git a/src/lib/images.ts b/src/lib/images.ts index f1529dd8d..a3e1b2e77 100644 --- a/src/lib/images.ts +++ b/src/lib/images.ts @@ -122,6 +122,15 @@ export async function resizeImage( ): Promise { const { signal, ...resizeOptions } = options; + const parsed = new URL(input); + if (parsed.protocol === 'data:') { + throw new Error('Cannot resize data: URLs'); + } + + if (parsed.hostname === 'localhost') { + throw new Error('Cannot resize localhost URLs'); + } + // Since Cloudflare Images options on fetch are not supported on Cloudflare Pages, // we need to use the Cloudflare Image Resize API directly. if (process.env.GITBOOK_IMAGE_RESIZE_URL) {