[ 
https://issues.apache.org/jira/browse/WW-4862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16216482#comment-16216482
 ] 

Lukasz Lenart commented on WW-4862:
-----------------------------------

Great, thank you for help :)

> Default Multipart validation regex is invalid due to charset encoding
> ---------------------------------------------------------------------
>
>                 Key: WW-4862
>                 URL: https://issues.apache.org/jira/browse/WW-4862
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Dispatch Filter
>    Affects Versions: 2.5.13
>         Environment: JDK8
> Tomcat 8.0
> Struts 2.5.13
>            Reporter: Paolo Perliti
>              Labels: charset, multipart, regex, struts2
>             Fix For: 2.5.14
>
>
> Struts 2.5.12 introduced a regex matches for multipart requests. 
> Struts 2.5.13 fixed WW-4818 issue, still it does fails due to charset 
> encoding being appended after the boundary marker (the regex does not match).
> Here's the header sent in browser's request:
> {code}
> Content-Type: multipart/form-data; 
> boundary=---------------------------207103069210263
> {code}
> And this is the header handled in Struts' Dispatcher wrapRequest() method:
> {code}
> multipart/form-data; 
> boundary=---------------------------207103069210263;charset=UTF-8
> {code}
> The issue seems to be related to the _applyEncoding _method (called in 
> _prepare_ method)
> {code:title=Dispatcher.java|borderStyle=solid}
>     private void applyEncoding(HttpServletRequest request, String encoding) {
>         try {
>             if (!encoding.equals(request.getCharacterEncoding())) {
>                 // if the encoding is already correctly set and the 
> parameters have been already read
>                 // do not try to set encoding because it is useless and will 
> cause an error
>                request.setCharacterEncoding(encoding);
>             }
>         } catch (Exception e) {
>             LOG.error("Error setting character encoding to '{}' - ignoring.", 
> encoding, e);
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to