Fixes successRedirectUrl validation

pull/3676/head
zomars 2022-08-01 18:20:40 -06:00
parent 14443099e0
commit 6179b3fbe0
2 changed files with 8 additions and 13 deletions

View File

@ -854,7 +854,6 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
seatsPerTimeSlot, seatsPerTimeSlot,
recurringEvent, recurringEvent,
locations, locations,
successRedirectUrl,
...input ...input
} = values; } = values;
@ -868,7 +867,6 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
id: eventType.id, id: eventType.id,
beforeEventBuffer: beforeBufferTime, beforeEventBuffer: beforeBufferTime,
afterEventBuffer: afterBufferTime, afterEventBuffer: afterBufferTime,
successRedirectUrl: successRedirectUrl || undefined,
seatsPerTimeSlot, seatsPerTimeSlot,
metadata: { metadata: {
...(smartContractAddress ? { smartContractAddress } : {}), ...(smartContractAddress ? { smartContractAddress } : {}),

View File

@ -118,15 +118,12 @@ export const userMetadata = z
* - XSS attempts through javascript:alert('hi') * - XSS attempts through javascript:alert('hi')
* - mailto: links * - mailto: links
*/ */
export function assertValidUrl(url: string) {
return url.startsWith("http://") && url.startsWith("https://");
}
export const successRedirectUrl = z export const successRedirectUrl = z
.union([
z.literal(""),
z
.string() .string()
.url() .url()
.refine(assertValidUrl, { .regex(/^http(s)?:\/\/.*/),
path: ["successRedirectUrl"], ])
message: "Invalid URL", .optional();
})
.nullish();