Skip to content

Commit

Permalink
Merge pull request #1371 from symfony/autocomplete-off
Browse files Browse the repository at this point in the history
[stimulus-bundle] Use defaultValue to change the value of hidden CSRF fields
  • Loading branch information
fabpot authored Jan 6, 2025
2 parents d061eb3 + b14ca06 commit 7e10c1d
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 7e10c1d

Please sign in to comment.