From 048339a6aacd09adc187f46484f1ceb90dfef371 Mon Sep 17 00:00:00 2001
From: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Sat, 8 Jun 2024 14:32:28 +0200
Subject: [bugfix] Use re2 syntax for regex validation (#2978)

---
 .../settings/views/admin/http-header-permissions/create.tsx      | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'web/source/settings/views/admin/http-header-permissions/create.tsx')

diff --git a/web/source/settings/views/admin/http-header-permissions/create.tsx b/web/source/settings/views/admin/http-header-permissions/create.tsx
index b791ae0a9..6613ac0f1 100644
--- a/web/source/settings/views/admin/http-header-permissions/create.tsx
+++ b/web/source/settings/views/admin/http-header-permissions/create.tsx
@@ -24,6 +24,7 @@ import useFormSubmit from "../../../lib/form/submit";
 import { TextInput } from "../../../components/form/inputs";
 import MutationButton from "../../../components/form/mutation-button";
 import { PermType } from "../../../lib/types/perm";
+import { RE2JS } from "re2js";
 
 export default function HeaderPermCreateForm({ permType }: { permType: PermType }) {
 	const form = {
@@ -56,7 +57,7 @@ export default function HeaderPermCreateForm({ permType }: { permType: PermType
 
 				// Ensure regex compiles.
 				try {
-					new RegExp(val);
+					RE2JS.compile(val);
 				} catch (e) {
 					return e;
 				}
@@ -116,14 +117,14 @@ export default function HeaderPermCreateForm({ permType }: { permType: PermType
 				field={form.regex}
 				label={
 					<>
-						HTTP Header Value Regex&nbsp;
+						HTTP Header Value RE2 Regex&nbsp;
 						<a
-							href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions"
+							href="https://github.com/google/re2/wiki/Syntax"
 							target="_blank"
 							className="docslink"
 							rel="noreferrer"
 						>
-							Learn more about regular expressions (opens in a new tab)
+							Learn more about RE2 regular expressions (opens in a new tab)
 						</a>
 					</>
 				}
-- 
cgit v1.2.3

