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

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

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


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.


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

Posted by "Tsutomu YANO (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594815#action_12594815 ] 

t_yano edited comment on WICKET-1569 at 5/7/08 2:55 AM:
--------------------------------------------------------------

encodeURIComponent is introduced by JavaScript 1.5, and the browsers, which Wicket officially support for Ajax (http://cwiki.apache.org/WICKET/faqs.html#FAQs-WhichbrowsershavebeentestedwithWicketAJAX%253F), are supporting JavaScript 1.5.

So encodeURIComponent is used always on the browsers.

  The effect of escape/unescape functions is depend on browswers, not on a specification. And escape/unescape functions can not encode/decode multi-byte strings correctly. So I never use that in my program.

  But the functions work correctly for single-byte string. So the if-else block is effective yet for such users with old browser. If you want to support old browsers, you can leave the block as is.

  There is no way to support old browsers with multi-byte string. You can simplly say them: Use a new browser supporting JavaScript 1.5.

      was (Author: t_yano):
    encodeURIComponent is introduced by JavaScript 1.5, and the browsers, which Wicket officially support for Ajax (http://cwiki.apache.org/WICKET/faqs.html#FAQs-WhichbrowsershavebeentestedwithWicketAJAX%253F), are supporting JavaScript 1.5.

So encodeURIComponent is used always on the browsers.

  The effect of encode/decode functions is depend on browswers, not on a specification. And encode/decode functions can not encode/decode multi-byte strings correctly. So I never use that in my program.

  But the functions work correctly for single-byte string. So the if-else block is effective yet for such users with old browser. If you want to support old browsers, you can leave the block as is.

  There is no way to support old browsers with multi-byte string. You can simplly say them: Use a new browser supporting JavaScript 1.5.
  
> 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.


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

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ 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.


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

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595918#action_12595918 ] 

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

are you sure escape is incorrect? What does a norma form post do? if i would type "this is me" in a text field? Would the spaces be converted to %20 or not?
Dont know so i let the escape be.

> 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, 1.4-M2
>
>
> 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.


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

Posted by "Tsutomu YANO (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594815#action_12594815 ] 

Tsutomu YANO commented on WICKET-1569:
--------------------------------------

encodeURIComponent is introduced by JavaScript 1.5, and the browsers, which Wicket officially support for Ajax (http://cwiki.apache.org/WICKET/faqs.html#FAQs-WhichbrowsershavebeentestedwithWicketAJAX%253F), are supporting JavaScript 1.5.

So encodeURIComponent is used always on the browsers.

  The effect of encode/decode functions is depend on browswers, not on a specification. And encode/decode functions can not encode/decode multi-byte strings correctly. So I never use that in my program.

  But the functions work correctly for single-byte string. So the if-else block is effective yet for such users with old browser. If you want to support old browsers, you can leave the block as is.

  There is no way to support old browsers with multi-byte string. You can simplly say them: Use a new browser supporting JavaScript 1.5.

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


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

Posted by "Tsutomu YANO (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594845#action_12594845 ] 

Tsutomu YANO commented on WICKET-1569:
--------------------------------------

Today I made a discussion about this issue with my friends, and could get some good opinions from them.

- the use of escape and encodeURIComponent is different. escape() is not the function to encode URI. So it should not be used at same place with encodeURIComponent.

  - the purpose of encodeURIComponent function is: To transform URI elements into safely postable form for servers.
  - the purpose of escape function is: To transform raw string data into safely displayable form for browsers.
  
therefore, now I think that you should not use the escape function to encode POST data, should change the if-else block and use only encodeURIComponent function.

Thanks.

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


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

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner closed WICKET-1569.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4-M2

> 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, 1.4-M2
>
>
> 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.


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

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1569?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner updated WICKET-1569:
------------------------------------

    Fix Version/s: 1.3.4
         Assignee: Johan Compagner

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