You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Johan Compagner (JIRA)" <ji...@apache.org> on 2008/05/04 18:14:55 UTC

[jira] Commented: (WICKET-1569) AjaxButton break form data when IRequestSettings.#getResponseRequestEncoding is not UTF-8.

    [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594104#action_12594104 ] 

Johan Compagner commented on WICKET-1569:
-----------------------------------------

i can apply this patch just fine, i am just thinking will it always be true?
for example i see that we use an if:

if (encodeURIComponent) {
        return encodeURIComponent(text);
    } else {
        return escape(text);
    }
then we just escape()

what happens then? Or is that encode always used?

> AjaxButton break form data when IRequestSettings.#getResponseRequestEncoding is not UTF-8.
> ------------------------------------------------------------------------------------------
>
>                 Key: WICKET-1569
>                 URL: https://issues.apache.org/jira/browse/WICKET-1569
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.3
>            Reporter: Tsutomu YANO
>            Assignee: Johan Compagner
>             Fix For: 1.3.4
>
>
> The AjaxButton encode all of input string by 'encodeUrlComponent()' JavaScript function at Wicket.Form.encode. The function encode the input string always by UTF-8 (it's a specification of ECMAScript), but WicketFilter always decode it by the encoding defined by the IRequestSettings#setResponseRequestEncoding() method.
> So if the response encoding is not UTF-8, all the input data will be broken at the decoding time. As a workaround,  we can avoid the problem by setting the output encoding to "UTF-8". But many web sites is using other encodings than UTF-8. For example, people often use "Shift_JIS" encoding for web site in Japan(It is a most popular encoding in Japan).
> To fix this problem, I think, you need to change WicketFilter class and check request headers when you decode input data. If the request has a 'wicket-ajax' header and the value is 'true', you need decode the posted data by 'UTF-8'. Otherwise decode them by the encoding defined by IRequestSettings#setResponseRequestEncoding();
> The changed code is below. It is a modification code at line 286 of WicketFilter class of Wicket 1.3.3.
> ======================
> if (servletRequest.getCharacterEncoding() == null) {
>     try {
>         // It this request is a wicket-ajax request, we need decode the
>         // request always by UTF-8, because the request data is encoded by
>         // encodeUrlComponent() JavaScript function, which always encode data 
>         // by UTF-8.
>         String wicketAjaxHeader = servletRequest.getHeader("wicket-ajax");
>         if(wicketAjaxHeader != null && wicketAjaxHeader.equals("true")) {
>             servletRequest.setCharacterEncoding("UTF-8");
>         } else {
>             // The encoding defined by the wicket settings is used to
>             // encode the responses. Thus, it is reasonable to assume
>             // the request has the same encoding. This is especially
>             // important for forms and form parameters.
>             servletRequest.setCharacterEncoding(webApplication.getRequestCycleSettings().getResponseRequestEncoding());
>         }
>     } catch (UnsupportedEncodingException ex) {
>         throw new WicketRuntimeException(ex.getMessage());
>     }
> }
> =======================
>  Thanks.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.