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:29:14 UTC

[myfaces] branch 3.0.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 3.0.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/3.0.x by this push:
     new 7f917e444 https://issues.apache.org/jira/browse/MYFACES-4532: Fix for MYFACES-4532
     new b166a5240 Merge pull request #482 from werpu/3.0.x
7f917e444 is described below

commit 7f917e4446db8e4f9440b78974f852f1c4bf5069
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 f969ceda3..8b728a9a1 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
@@ -1291,7 +1291,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":
@@ -1300,9 +1302,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;
                         }
                     }
@@ -1311,7 +1313,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;
                         }
                     }
@@ -1321,9 +1323,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