This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/release18.12 by this push: new c84b388 Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396) c84b388 is described below commit c84b388b85e17b5a7446f8d8cc1fbc1b29ef939a Author: Jacques Le Roux <jacques.le.r...@les7arts.com> 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;