[ofbiz-framework] branch trunk updated: Fixed: (OFBIZ-)

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

[ofbiz-framework] branch trunk updated: Fixed: (OFBIZ-)

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-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5170e9d  Fixed: (OFBIZ-)
5170e9d is described below

commit 5170e9d89503afa13d4ea1492b0ba73b2f92e528
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Sat Nov 9 14:25:00 2019 +0100

    Fixed:
    (OFBIZ-)
   
    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 17ab0ae..b7cab04 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;
@@ -96,6 +99,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;
@@ -218,7 +234,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;