You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/10/22 16:39:03 UTC

[jira] [Commented] (WW-4862) Default Multipart validation regex is invalid due to charset encoding

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

ASF GitHub Bot commented on WW-4862:
------------------------------------

lukaszlenart opened a new pull request #176: WW-4862: Multipart regex
URL: https://github.com/apache/struts/pull/176
 
 
   Fixes issue [WW-4862](https://issues.apache.org/jira/browse/WW-4862)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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