From 7acabb04714bee749c43b324e45e2d07d16c9985 Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 11 Dec 2018 22:01:05 +0100 Subject: [PATCH] Fixed an error in the CSRF tag storage. --- assets/typescript/FormUtilities.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/typescript/FormUtilities.ts b/assets/typescript/FormUtilities.ts index 0db71bfa..286b34a9 100644 --- a/assets/typescript/FormUtilities.ts +++ b/assets/typescript/FormUtilities.ts @@ -56,12 +56,16 @@ const CSRFTokenStore: CSRFToken[] = []; function initCSRF(): void { const csrfTokens: NodeListOf = document.querySelectorAll('[name^="csrf["]'), - regex = /\[([a-z]+)\]/iu, + regex = /\[([A-Za-z0-9_-]+)\]/iu, handled: string[] = []; for (let i = 0; i < csrfTokens.length; i++) { let csrfToken: HTMLInputElement = csrfTokens[i], - realm: string = csrfToken.name.match(regex)[1] || ''; + matches: string[] = csrfToken.name.match(regex); + + if (matches.length < 2) + continue; + let realm: string = matches[1]; if (handled.indexOf(realm) >= 0) continue;