Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Release Branch 18.12, Release Branch 17.12, Trunk
-
None
-
OFBiz Community Day (Feb 2020)
Description
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.
I stumbled upon this issue on Windows while using webtools/control/entityref:
Caused by: java.util.regex.PatternSyntaxException: Unknown character property name {r} near index 4 C:\projectsASF\Git\ofbiz-framework/ ^ at java.util.regex.Pattern.error(Pattern.java:1957) ~[?:1.8.0_202] at java.util.regex.Pattern.charPropertyNodeFor(Pattern.java:2783) ~[?:1.8.0_202] at java.util.regex.Pattern.family(Pattern.java:2738) ~[?:1.8.0_202] at java.util.regex.Pattern.sequence(Pattern.java:2078) ~[?:1.8.0_202] at java.util.regex.Pattern.expr(Pattern.java:1998) ~[?:1.8.0_202] at java.util.regex.Pattern.compile(Pattern.java:1698) ~[?:1.8.0_202] at java.util.regex.Pattern.<init>(Pattern.java:1351) ~[?:1.8.0_202] at java.util.regex.Pattern.compile(Pattern.java:1028) ~[?:1.8.0_202] at java.lang.String.replaceFirst(String.java:2178) ~[?:1.8.0_202] at org.apache.ofbiz.webtools.WebToolsServices.getEntityRefData(WebToolsServices.java:770) ~[main/:?]
The simplest solution is to replace replaceFirst by StringUtils.replaceOnce.