This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release17.12
in repository
https://gitbox.apache.org/repos/asf/ofbiz-plugins.gitThe following commit(s) were added to refs/heads/release17.12 by this push:
new 3d37294 Fixed: replaceFirst sensible to variable pattern (OFBIZ-11396)
3d37294 is described below
commit 3d37294014ac612bd3ef9dc80064dbd5e3c6eb72
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 4fbe2ff..877a8df 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,11 +25,12 @@ 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.security.Security;
import org.apache.ofbiz.webapp.control.LoginWorker;
+import org.apache.solr.servlet.RedirectServlet;
/**
* OFBizSolrRedirectServlet.java - Master servlet for the ofbiz-solr application.
@@ -68,11 +69,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;