Fixed an error in the CSRF tag storage.

This commit is contained in:
flash 2018-12-11 22:01:05 +01:00
parent 8d58bdb40e
commit 7acabb0471

View file

@ -56,12 +56,16 @@ const CSRFTokenStore: CSRFToken[] = [];
function initCSRF(): void { function initCSRF(): void {
const csrfTokens: NodeListOf<HTMLInputElement> = document.querySelectorAll('[name^="csrf["]'), const csrfTokens: NodeListOf<HTMLInputElement> = document.querySelectorAll('[name^="csrf["]'),
regex = /\[([a-z]+)\]/iu, regex = /\[([A-Za-z0-9_-]+)\]/iu,
handled: string[] = []; handled: string[] = [];
for (let i = 0; i < csrfTokens.length; i++) { for (let i = 0; i < csrfTokens.length; i++) {
let csrfToken: HTMLInputElement = csrfTokens[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) if (handled.indexOf(realm) >= 0)
continue; continue;