[ofbiz-plugins] branch trunk updated: Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396)

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

[ofbiz-plugins] branch trunk updated: Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396)

jleroux@apache.org
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-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new a42ac97  Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396)
a42ac97 is described below

commit a42ac97ce9ee69d0905c60296505f6a3b65824f9
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Sat Feb 22 07:21:21 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.
---
 .../org/apache/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java b/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java
index 0886593..4e13400 100644
--- a/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java
+++ b/solr/src/main/java/org/apache/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java
@@ -25,10 +25,11 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
-import org.apache.solr.servlet.RedirectServlet;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.webapp.control.LoginWorker;
+import org.apache.solr.servlet.RedirectServlet;
 
 /**
  * OFBizSolrRedirectServlet.java - Master servlet for the ofbiz-solr application.
@@ -67,11 +68,11 @@ public class OFBizSolrRedirectServlet extends RedirectServlet {
             String contextPath = request.getContextPath();
             String uri = request.getRequestURI();
             if (UtilValidate.isNotEmpty(contextPath) && uri.startsWith(contextPath)) {
-                uri = uri.replaceFirst(request.getContextPath(), "");
+                uri = StringUtils.replaceOnce(uri, request.getContextPath(), "");
             }
             String servletPath = request.getServletPath();
             if (UtilValidate.isNotEmpty(servletPath) && uri.startsWith(servletPath)) {
-                uri = uri.replaceFirst(servletPath, "");
+                uri = StringUtils.replaceOnce(uri, servletPath, "");
             }
             response.sendRedirect(contextPath + "/control/checkLogin" + uri);
             return true;