You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2020/02/22 06:32:20 UTC
[ofbiz-framework] branch trunk updated: Fixed: replaceFirst
sensible to variable pattern (OFBIZ-11396)
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 549543a Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396)
549543a is described below
commit 549543ace5d7a67622b16aecafc9a2104fb16a35
Author: Jacques Le Roux <ja...@les7arts.com>
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.
---
.../src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java | 3 ++-
.../src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java | 3 ++-
2 files changed, 4 insertions(+), 2 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 d29ab94..87626f3 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;
@@ -358,7 +359,7 @@ public class UelFunctions {
public static String replaceFirst(String str1, String str2, String str3) {
if (null == str1) return null;
- return str1.replaceFirst(str2, str3);
+ 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 262eb64..358a94a 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;
@@ -767,7 +768,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);