This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release17.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release17.12 by this push: new afae70b Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396) afae70b is described below commit afae70b71a7602543b289d5c4ffce505bc09161e Author: Jacques Le Roux <[hidden email]> AuthorDate: Sat Feb 22 07:21:09 2020 +0100 Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396) When using variable pattern with replaceFirst you may cross issues if the pattern contains specific tokens. For instance on Windows with the path "C:\projectsASF\Git\ofbiz-framework/" you have inside the token "\p" which has a special meaning. --- .../main/java/org/apache/ofbiz/base/util/string/UelFunctions.java | 7 +++---- .../src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java index d0b99ad..d01e338 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java @@ -41,6 +41,7 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; +import org.apache.commons.lang3.StringUtils; import org.apache.ofbiz.base.location.FlexibleLocation; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.FileUtil; @@ -374,10 +375,8 @@ public class UelFunctions { } public static String replaceFirst(String str1, String str2, String str3) { - try { - return str1.replaceFirst(str2, str3); - } catch (Exception e) {} - return null; + if (null == str1) return null; + return StringUtils.replaceOnce(str1, str2, str3); } public static boolean startsWith(String str1, String str2) { diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java index 3f25c61..4e660a3 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java @@ -48,6 +48,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.lang3.StringUtils; import org.apache.ofbiz.base.location.FlexibleLocation; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.GeneralException; @@ -761,7 +762,7 @@ public class WebToolsServices { entityMap.put("title", entity.getTitle()); entityMap.put("description", entityDescription); String entityLocation = entity.getLocation(); - entityLocation = entityLocation.replaceFirst(System.getProperty("ofbiz.home") + "/", ""); + entityLocation = StringUtils.replaceOnce(entityLocation, System.getProperty("ofbiz.home") + "/", ""); entityMap.put("location", entityLocation); entityMap.put("javaNameList", javaNameList); entityMap.put("relationsList", relationsList); |
Free forum by Nabble | Edit this page |