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-framework.gitThe following commit(s) were added to refs/heads/release17.12 by this push:
new 0d6bfb2 Fixed: SeoContextFilter.java is not able to handle query strings (OFBIZ-11278)
0d6bfb2 is described below
commit 0d6bfb2ca8a241b7487f4adf657414e9ce97f99a
Author: Jacques Le Roux <
[hidden email]>
AuthorDate: Sat Nov 9 14:25:00 2019 +0100
Fixed: SeoContextFilter.java is not able to handle query strings
(OFBIZ-11278)
While working on OFBIZ-9804 (verification email for Newsletter) I was confronted
with misc. issues. One of them was that SeoContextFilter.java was not handling
query strings.
This fixes it
---
.../ofbiz/product/category/SeoContextFilter.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java
index 505024c..b57976d 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/product/category/SeoContextFilter.java
@@ -20,6 +20,7 @@ package org.apache.ofbiz.product.category;
import java.io.IOException;
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -41,6 +42,8 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.message.BasicNameValuePair;
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilHttp;
@@ -97,6 +100,19 @@ public class SeoContextFilter implements Filter {
HttpServletResponse httpResponse = (HttpServletResponse) response;
String uri = httpRequest.getRequestURI();
+
+ Map<String, String[]> parameterMap =request.getParameterMap();
+ if (parameterMap != null) {
+ List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
+ request.getParameterMap().forEach((name, values) -> {
+ for(String value : values) {
+ params.add(new BasicNameValuePair(name, value));
+ }
+ });
+ String queryString = URLEncodedUtils.format(params, Charset.forName("UTF-8"));
+ uri = uri + "?" + queryString;
+ }
+
boolean forwarded = forwardUri(httpResponse, uri);
if (forwarded) {
return;
@@ -219,7 +235,7 @@ public class SeoContextFilter implements Filter {
* @param uri String to reverse transform
* @return String
*/
- protected static boolean forwardUri(HttpServletResponse response, String uri) {
+ private static boolean forwardUri(HttpServletResponse response, String uri) {
Perl5Matcher matcher = new Perl5Matcher();
boolean foundMatch = false;
Integer responseCodeInt = null;