Skip to content

Commit 63c7778

Browse files
Merge pull request #4417 from IgorA100/patch-654353
Fix: Do not generate global variables "form" and "forms" (csrf-magic.js)
2 parents f047176 + 9450799 commit 63c7778

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

web/includes/csrf/csrf-magic.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
// Here are the basic overloaded method definitions
99
// The wrapper must be set BEFORE onreadystatechange is written to, since
1010
// a bug in ActiveXObject prevents us from properly testing for it.
11-
CsrfMagic = function(real) {
11+
// "use strict";
12+
var CsrfMagic = function(real) {
1213
// try to make it ourselves, if you didn't pass it
1314
if (!real) try {real = new XMLHttpRequest;} catch (e) {;}
1415
if (!real) try {real = new ActiveXObject('Msxml2.XMLHTTP');} catch (e) {;}
@@ -101,9 +102,9 @@ CsrfMagic.process = function(base) {
101102
CsrfMagic.end = function() {
102103
// This rewrites forms AGAIN, so in case buffering didn't work this
103104
// certainly will.
104-
forms = document.getElementsByTagName('form');
105+
const forms = document.getElementsByTagName('form');
105106
for (var i = 0; i < forms.length; i++) {
106-
form = forms[i];
107+
const form = forms[i];
107108
if (form.method.toUpperCase() !== 'POST') continue;
108109
if (form.elements[csrfMagicName]) continue;
109110
var input = document.createElement('input');

0 commit comments

Comments
 (0)