Hello,

I noticed a very weird error affecting MyFaces 2.3.0 and 2.3.1 in combination with IE 11 (and maybe other IEs, we only test against IE 11). Chrome, Firefox and Edge seem to NOT be affected.

On IE when _applyJSFArtifactValueToForm() is run as part of processResponse() it might occur that indexOf() is called on undefined, since e.name can be undefined in IE 11 if something like e.g. a <filedset> is inside the Form and it has no name set. For the other Browsers this resolves to e.name (in line 242 in _AjaxResponse.js, HEAD @ Tag myfaces-core-module-2.3.1) being "" (i.e. empty String), which seems to be a great idea for a sensible default. But not so for IE 11: it has e.name undefined, hence calling indexOf() on it causes a TypeError, which in turn leads for any hidden input (e.g. ViewState) to not be updated.

In our stack (MyFaces with Primefaces and DeltaSpike) this leads to WindowScope not being active after the Response of the first Ajax is processed.

The issue can be fixed with the patch appended to this EMail.

MyFaces 2.2.12 is NOT affected.

If further work is needed I am happy to help.

Kind regards,

Juri Berlanda

>From b9f338c43db7f2113280d027d1586aa6d8d393ca Mon Sep 17 00:00:00 2001
From: Juri Berlanda <juri.berla...@tuwien.ac.at>
Date: Wed, 9 May 2018 19:10:50 +0200
Subject: [PATCH] Fix TypeError in IE 11.

IE 11 seems to have a the "name" property undefined by default, while other
browsers fall back to empty String. This means e.name needs to be checked
before calling indexOf() on it.
---
 .../META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
index 5254efc..21e451f 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
@@ -239,7 +239,7 @@ _MF_SINGLTN(_PFX_XHR + "_AjaxResponse", _MF_OBJECT, /** @lends myfaces._impl.xhr
         var elements = theForm.elements;
         for (var i = 0, l = elements.length; i < l; i++) {
             var e = elements[i];
-            if (e.name.indexOf(identifier) != -1) {
+            if ((typeof e.name !== "undefined") && e.name.indexOf(identifier) != -1) {
                 fieldsFound.push(e);
             }
         }
-- 
2.7.4

Reply via email to