[jira] [Created] (OFBIZ-11396) replaceFirst sensible to variable pattern

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (OFBIZ-11396) replaceFirst sensible to variable pattern

Nicolas Malin (Jira)
Jacques Le Roux created OFBIZ-11396:
---------------------------------------

             Summary: replaceFirst sensible to variable pattern
                 Key: OFBIZ-11396
                 URL: https://issues.apache.org/jira/browse/OFBIZ-11396
             Project: OFBiz
          Issue Type: Bug
          Components: framework/webtools, solr
    Affects Versions: Trunk, Release Branch 17.12, Release Branch 18.12
            Reporter: Jacques Le Roux
            Assignee: Jacques Le Roux
             Fix For: 17.12.01, 18.12.01


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|https://www.regular-expressions.info/unicode.html].

I stumbled upon this issue on Windows while using webtools/control/entityref:

{noformat}
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/:?]
{noformat}

The simplest solution is to replace replaceFirst by StringUtils.replaceOnce.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)