You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2023/01/16 12:28:29 UTC

[myfaces] branch 2.3.x updated: https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532

This is an automated email from the ASF dual-hosted git repository.

werpu pushed a commit to branch 2.3.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.3.x by this push:
     new f999644cc https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532
     new 62602fe87 Merge pull request #480 from werpu/2.3.x
f999644cc is described below

commit f999644cc3959a9e9844dbd025783304f20d715b
Author: Werner Punz <we...@gmail.com>
AuthorDate: Mon Jan 16 13:17:40 2023 +0100

    https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532
---
 .../META-INF/resources/myfaces/_impl/_util/_Dom.js       | 12 +++++++-----
 .../META-INF/resources/myfaces/_impl/_util/_Lang.js      | 16 ++++++++++++++++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
index 12ea4d648..f1dbf3125 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
@@ -1285,7 +1285,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
 
         //we filter out only those evalNodes which do not match
         var _RT = this._RT;
+        var _Lang = this._Lang;
         var _T = this;
+
         var doubleExistsFilter = function(item)  {
             switch((item.tagName || "").toLowerCase()) {
                 case "script":
@@ -1294,9 +1296,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
                     var scripts = document.head.getElementsByTagName("script");
 
                     for(var cnt = 0; cnt < scripts.length; cnt++) {
-                        if(src && scripts[cnt].getAttribute("src") == src) {
+                        if(src && _Lang.match(scripts[cnt].getAttribute("src"), src)) {
                             return false;
-                        } else if(!src && scripts[cnt].innerText == content) {
+                        } else if(!src && _Lang.match(scripts[cnt].innerText, content)) {
                             return false;
                         }
                     }
@@ -1305,7 +1307,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
                     var content = item.innerText;
                     var styles = document.head.getElementsByTagName("style");
                     for(var cnt = 0; cnt < styles.length; cnt++) {
-                        if(content && styles[cnt].innerText == content) {
+                        if(content && _Lang.match(styles[cnt].innerText, content)) {
                             return false;
                         }
                     }
@@ -1315,9 +1317,9 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object, /** @lends myfaces._impl._util._Dom.prot
                     var content = item.innerText;
                     var links = document.head.getElementsByTagName("link");
                     for(var cnt = 0; cnt < links.length; cnt++) {
-                        if(href && links[cnt].getAttribute("href") == href) {
+                        if(href && _Lang.match(links[cnt].getAttribute("href"), href)) {
                             return false;
-                        } else if(!href && links[cnt].innerText == content) {
+                        } else if(!href && _Lang.match(links[cnt].innerText, content)) {
                             return false;
                         }
                     }
diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
index ceea1573c..e27fd5fb5 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
@@ -214,6 +214,22 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object, /** @lends myfaces._impl._util._Lang.pr
         }
         return str.slice(0, i + 1);
     },
+
+    /**
+     * a fuzzy match where one item is subset of the other or vice versa
+     * @param str1
+     * @param str2
+     * @returns {boolean}
+     */
+    match: function(str1, str2) {
+        //Sometimes we have to deal with paths in hrefs so
+        //one of the itmes either is an exact match or a substring
+        str1 = this.trim(str1 || "");
+        str2 = this.trim(str2 || "");
+
+        return str1.indexOf(str2) != -1 || str2.indexOf(str1) != -1;
+    },
+
     /**
      * Backported from dojo
      * a failsafe string determination method