From a8ca5f0e7447610c10b4dfad04919f0864ebc950 Mon Sep 17 00:00:00 2001
From: Mathias Brodala <mbrodala@pagemachine.de>
Date: Wed, 5 Aug 2015 17:52:55 +0200
Subject: [PATCH] [TASK] Use DOM API for field access in RSA encryption

DOM Level 2 provides collections for forms and form elements,
thus make use of them.

Resolves: #68765
Releases: master
Change-Id: I795b2c3348d7a39fdbe277df4c6661e3427c5e1f
Reviewed-on: http://review.typo3.org/42281
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
---
 .../Resources/Public/JavaScript/RsaEncryption.js  | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryption.js b/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryption.js
index 75c5426fd3fb..0ef3651e9813 100644
--- a/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryption.js
+++ b/typo3/sysext/rsaauth/Resources/Public/JavaScript/RsaEncryption.js
@@ -111,9 +111,8 @@
 			if (form.submit.call) {
 				form.submit.call(rsaEncryption.form);
 			} else {
-				var fields = rsaEncryption.form.getElementsByTagName('*');
-				for (var j = fields.length; j--;) {
-					var submitField = fields[j];
+				for (var j = rsaEncryption.form.elements.length; j--;) {
+					var submitField = rsaEncryption.form.elements[j];
 					if (submitField.nodeName.toLowerCase() === 'input' && submitField.type === "submit") {
 						submitField.click();
 					}
@@ -132,12 +131,10 @@
 
 		documentReadyFunctionCalled = true;
 		rng_seed_time();
-		var forms = document.getElementsByTagName('form');
-		for (var i = forms.length; i--;) {
-			var form = forms[i];
-			var fields = form.getElementsByTagName('*');
-			for (var j = fields.length; j--;) {
-				var field = fields[j];
+		for (var i = document.forms.length; i--;) {
+			var form = document.forms[i];
+			for (var j = form.elements.length; j--;) {
+				var field = form.elements[j];
 				if (field.nodeName.toLowerCase() === 'input') {
 					var dataAttribute = field.getAttribute('data-rsa-encryption');
 					if (dataAttribute || dataAttribute === '' && field.outerHTML.match(/ data-rsa-encryption=""/)) {
-- 
GitLab