Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(shared): express the URL scheme check without a control-character regex

Maurice502a3fd4e841
diff --git a/shared/src/reservation/reservation.schema.ts b/shared/src/reservation/reservation.schema.ts
index 89c9b6131..ab5e66fae 100644
--- a/shared/src/reservation/reservation.schema.ts
+++ b/shared/src/reservation/reservation.schema.ts
@@ -212,8 +212,9 @@ export type Accommodation = z.infer<typeof accommodationSchema>;
*/
export const reservationUrlSchema = z.string().refine(
// Browsers strip control characters and whitespace before they resolve the
- // scheme, so a tab spliced into 'javascript:' still runs.
- v => !/^(javascript|data|vbscript):/i.test(v.replace(/[\u0000-\u0020]/g, '')),
+ // scheme, so a tab spliced into 'javascript:' still runs. Everything at
+ // or below U+0020 goes, which is the same set a browser drops.
+ v => !/^(javascript|data|vbscript):/i.test(Array.from(v).filter(c => c > ' ').join('')),
{ message: 'must not be a javascript:, data: or vbscript: URL' },
);