From b94bf9c3aae514b471a5f56b4eb835366c034d5a Mon Sep 17 00:00:00 2001 From: TheWitness Date: Mon, 11 Nov 2024 11:23:23 -0500 Subject: [PATCH] QA: Fix issue with CSRF failing on no method passed --- include/vendor/csrf/csrf-magic.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/vendor/csrf/csrf-magic.js b/include/vendor/csrf/csrf-magic.js index 7cacd6da5a..8eac61b70c 100644 --- a/include/vendor/csrf/csrf-magic.js +++ b/include/vendor/csrf/csrf-magic.js @@ -106,7 +106,11 @@ CsrfMagic.end = function() { forms = document.getElementsByTagName('form'); for (var i = 0; i < forms.length; i++) { form = forms[i]; - if (form.method.toUpperCase() !== 'POST') continue; + + if (typeof form.method.toUpperCase == 'function' && form.method.toUpperCase() !== 'POST') { + continue; + } + if (form.elements[csrfMagicName]) continue; var input = document.createElement('input'); input.setAttribute('name', csrfMagicName);