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.
This commit is contained in:
Jacques Le Roux
2020-02-22 07:30:46 +01:00
parent 872c329618
commit afae70b71a
2 changed files with 5 additions and 5 deletions
@@ -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) {