Skip to content

Commit

Permalink
[stimulus-bundle] Use defaultValue to change the value of hidden CSRF…
Browse files Browse the repository at this point in the history
… fields
  • Loading branch information
nicolas-grekas committed Jan 6, 2025
1 parent 5f3e6c5 commit b14ca06
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit b14ca06

Please sign in to comment.