From 33ea9f3ba2df576cd3e7f4ada56e09fff1488bec Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <bfr@qbus.de>
Date: Tue, 14 Dec 2021 13:17:34 +0100
Subject: [PATCH] [BUGFIX] Fix scoping issue in FormEngineValidation

theChar is not initialized and therefore pollutes global scope.
(It is assigned to window.theChar in the FormEngine iframe).

Currently not an error (we are not using strict mode in RequireJS),
just bad style, but once we switch to strict mode (type="module"),
this will fail without proper declaration.

Releases: main, 11.5
Resolves: #96395
Related: #96323
Change-Id: Ie82da6a1b664e4010179cccaabb07e7d87b19038
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72735
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../backend/Resources/Public/JavaScript/FormEngineValidation.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
index 5d51a019ac64..894d50c145a7 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
@@ -429,7 +429,7 @@ define([
       case 'alphanum_x':
         newString = '';
         for (a = 0; a < value.length; a++) {
-          theChar = value.substr(a, 1);
+          var theChar = value.substr(a, 1);
           var special = (theChar === '_' || theChar === '-');
           var alpha = (theChar >= 'a' && theChar <= 'z') || (theChar >= 'A' && theChar <= 'Z');
           var num = (theChar >= '0' && theChar <= '9');
-- 
GitLab