From b14ca0650cec8c8f68de303666d9485a447bf1c1 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 29 Dec 2024 17:11:26 +0100 Subject: [PATCH] [stimulus-bundle] Use defaultValue to change the value of hidden CSRF fields --- .../2.20/assets/controllers/csrf_protection_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js b/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js index 6d42e5c9..075d06cd 100644 --- a/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js +++ b/symfony/stimulus-bundle/2.20/assets/controllers/csrf_protection_controller.js @@ -14,7 +14,7 @@ document.addEventListener('submit', function (event) { if (!csrfCookie && nameCheck.test(csrfToken)) { csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken); - csrfField.value = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18)))); + csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18)))); } if (csrfCookie && tokenCheck.test(csrfToken)) {