From 53de4ddaafe3baf34b452247dc268b5da8a3b81c Mon Sep 17 00:00:00 2001 From: zomars Date: Mon, 1 Aug 2022 18:45:47 -0600 Subject: [PATCH] Fixes successRedirectUrl commit b006240b0c62e9e62944cb7184793f099358e2ec Merge: 6179b3fbe e7418f68a Author: zomars Date: Mon Aug 1 18:20:47 2022 -0600 Merge branch 'main' into production commit 6179b3fbe06709f1cf3a4e54214a7dbb1543765e Author: zomars Date: Mon Aug 1 18:20:40 2022 -0600 Fixes successRedirectUrl validation commit 14443099e0377e8d9af52f53f15c2f8b91b784d2 Author: zomars Date: Mon Aug 1 17:59:47 2022 -0600 successRedirectUrl fixes --- apps/web/pages/event-types/[type].tsx | 2 -- packages/prisma/zod-utils.ts | 20 ++++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsx index 99c1c5e95c..2bcd7747fe 100644 --- a/apps/web/pages/event-types/[type].tsx +++ b/apps/web/pages/event-types/[type].tsx @@ -854,7 +854,6 @@ const EventTypePage = (props: inferSSRProps) => { seatsPerTimeSlot, recurringEvent, locations, - successRedirectUrl, ...input } = values; @@ -868,7 +867,6 @@ const EventTypePage = (props: inferSSRProps) => { id: eventType.id, beforeEventBuffer: beforeBufferTime, afterEventBuffer: afterBufferTime, - successRedirectUrl: successRedirectUrl || undefined, seatsPerTimeSlot, metadata: { ...(smartContractAddress ? { smartContractAddress } : {}), diff --git a/packages/prisma/zod-utils.ts b/packages/prisma/zod-utils.ts index edfe7f6142..bb84f58211 100644 --- a/packages/prisma/zod-utils.ts +++ b/packages/prisma/zod-utils.ts @@ -118,16 +118,12 @@ export const userMetadata = z * - XSS attempts through javascript:alert('hi') * - mailto: links */ -export function assertValidUrl(url: string | null | undefined) { - if (!url) return false; - return url.startsWith("http://") && url.startsWith("https://"); -} - export const successRedirectUrl = z - .string() - .url() - .refine(assertValidUrl, { - path: ["successRedirectUrl"], - message: "Invalid URL", - }) - .nullish(); + .union([ + z.literal(""), + z + .string() + .url() + .regex(/^http(s)?:\/\/.*/), + ]) + .optional();