You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Chatree Srichart <ch...@gmail.com> on 2012/03/06 08:02:08 UTC

Re: svn commit: r1297006 - in /ofbiz/trunk/framework: webapp/src/org/ofbiz/webapp/control/RequestHandler.java widget/src/org/ofbiz/widget/WidgetWorker.java

There is a problem with this patch. URLs which are encoded could not
redirect from HTTP to HTTPS. The error is shown on the demo site, for
example, http://demo-trunk.ofbiz.apache.org:8080/ecommerce/ which the
"Login" link does not work.

Regards,
Chatree Srichart

On Mon, Mar 5, 2012 at 6:13 PM, <sa...@apache.org> wrote:

> Author: sascharodekamp
> Date: Mon Mar  5 11:13:29 2012
> New Revision: 1297006
>
> URL: http://svn.apache.org/viewvc?rev=1297006&view=rev
> Log:
> No Url encoding for get parameters (
> https://issues.apache.org/jira/browse/OFBIZ-2628) using the URLEncoder to
> encode and render URLs with special Chars. The encoding is always UTF-8
>
> Modified:
>
>  ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
>    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
>
> Modified:
> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1297006&r1=1297005&r2=1297006&view=diff
>
> ==============================================================================
> ---
> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
> (original)
> +++
> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
> Mon Mar  5 11:13:29 2012
> @@ -24,6 +24,8 @@ import java.io.IOException;
>  import java.io.Serializable;
>  import java.io.UnsupportedEncodingException;
>  import java.net.URL;
> +import java.net.URLEncoder;
> +import java.nio.charset.Charset;
>  import java.security.cert.X509Certificate;
>  import java.util.Enumeration;
>  import java.util.List;
> @@ -1113,7 +1115,13 @@ public class RequestHandler {
>                         newURL.insert(questionIndex, sessionId);
>                     }
>                 }
> -                encodedUrl = newURL.toString();
> +
> +                try {
> +                    encodedUrl = URLEncoder.encode(newURL.toString(),
> Charset.forName("UTF-8").displayName());
> +                } catch (UnsupportedEncodingException e) {
> +                    Debug.logError(e, module);
> +                    encodedUrl = newURL.toString();
> +                }
>             }
>         } else {
>             encodedUrl = newURL.toString();
>
> Modified:
> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=1297006&r1=1297005&r2=1297006&view=diff
>
> ==============================================================================
> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
> (original)
> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
> Mon Mar  5 11:13:29 2012
> @@ -20,7 +20,10 @@ package org.ofbiz.widget;
>
>  import java.io.IOException;
>  import java.io.StringWriter;
> +import java.io.UnsupportedEncodingException;
>  import java.math.BigDecimal;
> +import java.net.URLEncoder;
> +import java.nio.charset.Charset;
>  import java.text.DateFormat;
>  import java.util.Map;
>  import java.util.TimeZone;
> @@ -339,7 +342,12 @@ public class WidgetWorker {
>
>         public String getValue(Map<String, Object> context) {
>             if (this.value != null) {
> -                return this.value.expandString(context);
> +                try {
> +                    return
> URLEncoder.encode(this.value.expandString(context),
> Charset.forName("UTF-8").displayName());
> +                } catch (UnsupportedEncodingException e) {
> +                    Debug.logError(e, module);
> +                    return this.value.expandString(context);
> +                }
>             }
>
>             Object retVal = null;
> @@ -370,7 +378,11 @@ public class WidgetWorker {
>                     DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM
> dd hh:mm:ss z yyyy", timeZone, null);
>                     returnValue = df.format((java.util.Date) retVal);
>                 } else {
> -                    returnValue = retVal.toString();
> +                    try {
> +                        returnValue =
> URLEncoder.encode(retVal.toString(),
> Charset.forName("UTF-8").displayName());
> +                    } catch (UnsupportedEncodingException e) {
> +                        Debug.logError(e, module);
> +                    }
>                 }
>                 return returnValue;
>             } else {
>
>
>

Re: svn commit: r1297006 - in /ofbiz/trunk/framework: webapp/src/org/ofbiz/webapp/control/RequestHandler.java widget/src/org/ofbiz/widget/WidgetWorker.java

Posted by Sascha Rodekamp <sa...@googlemail.com>.
Hi Chatree, i reverted the patch, the redirect should work again.

Thanks
Regards,
Sascha

2012/3/6 Chatree Srichart <ch...@gmail.com>:
> There is a problem with this patch. URLs which are encoded could not
> redirect from HTTP to HTTPS. The error is shown on the demo site, for
> example, http://demo-trunk.ofbiz.apache.org:8080/ecommerce/ which the
> "Login" link does not work.
>
> Regards,
> Chatree Srichart
>
> On Mon, Mar 5, 2012 at 6:13 PM, <sa...@apache.org> wrote:
>
>> Author: sascharodekamp
>> Date: Mon Mar  5 11:13:29 2012
>> New Revision: 1297006
>>
>> URL: http://svn.apache.org/viewvc?rev=1297006&view=rev
>> Log:
>> No Url encoding for get parameters (
>> https://issues.apache.org/jira/browse/OFBIZ-2628) using the URLEncoder to
>> encode and render URLs with special Chars. The encoding is always UTF-8
>>
>> Modified:
>>
>>  ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
>>    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
>>
>> Modified:
>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1297006&r1=1297005&r2=1297006&view=diff
>>
>> ==============================================================================
>> ---
>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
>> (original)
>> +++
>> ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
>> Mon Mar  5 11:13:29 2012
>> @@ -24,6 +24,8 @@ import java.io.IOException;
>>  import java.io.Serializable;
>>  import java.io.UnsupportedEncodingException;
>>  import java.net.URL;
>> +import java.net.URLEncoder;
>> +import java.nio.charset.Charset;
>>  import java.security.cert.X509Certificate;
>>  import java.util.Enumeration;
>>  import java.util.List;
>> @@ -1113,7 +1115,13 @@ public class RequestHandler {
>>                         newURL.insert(questionIndex, sessionId);
>>                     }
>>                 }
>> -                encodedUrl = newURL.toString();
>> +
>> +                try {
>> +                    encodedUrl = URLEncoder.encode(newURL.toString(),
>> Charset.forName("UTF-8").displayName());
>> +                } catch (UnsupportedEncodingException e) {
>> +                    Debug.logError(e, module);
>> +                    encodedUrl = newURL.toString();
>> +                }
>>             }
>>         } else {
>>             encodedUrl = newURL.toString();
>>
>> Modified:
>> ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=1297006&r1=1297005&r2=1297006&view=diff
>>
>> ==============================================================================
>> --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
>> (original)
>> +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
>> Mon Mar  5 11:13:29 2012
>> @@ -20,7 +20,10 @@ package org.ofbiz.widget;
>>
>>  import java.io.IOException;
>>  import java.io.StringWriter;
>> +import java.io.UnsupportedEncodingException;
>>  import java.math.BigDecimal;
>> +import java.net.URLEncoder;
>> +import java.nio.charset.Charset;
>>  import java.text.DateFormat;
>>  import java.util.Map;
>>  import java.util.TimeZone;
>> @@ -339,7 +342,12 @@ public class WidgetWorker {
>>
>>         public String getValue(Map<String, Object> context) {
>>             if (this.value != null) {
>> -                return this.value.expandString(context);
>> +                try {
>> +                    return
>> URLEncoder.encode(this.value.expandString(context),
>> Charset.forName("UTF-8").displayName());
>> +                } catch (UnsupportedEncodingException e) {
>> +                    Debug.logError(e, module);
>> +                    return this.value.expandString(context);
>> +                }
>>             }
>>
>>             Object retVal = null;
>> @@ -370,7 +378,11 @@ public class WidgetWorker {
>>                     DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM
>> dd hh:mm:ss z yyyy", timeZone, null);
>>                     returnValue = df.format((java.util.Date) retVal);
>>                 } else {
>> -                    returnValue = retVal.toString();
>> +                    try {
>> +                        returnValue =
>> URLEncoder.encode(retVal.toString(),
>> Charset.forName("UTF-8").displayName());
>> +                    } catch (UnsupportedEncodingException e) {
>> +                        Debug.logError(e, module);
>> +                    }
>>                 }
>>                 return returnValue;
>>             } else {
>>
>>
>>



-- 

Sascha Rodekamp
    Visit the new german OFBiz Blog: http://www.ofbiz.biz
    Lynx-Consulting GmbH
    Johanniskirchplatz 6
    D-33615 Bielefeld
    http://www.lynx.de