Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EDE3A200D0B for ; Wed, 27 Sep 2017 16:25:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EC5611609BC; Wed, 27 Sep 2017 14:25:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 16CF91609CA for ; Wed, 27 Sep 2017 16:25:08 +0200 (CEST) Received: (qmail 91815 invoked by uid 500); 27 Sep 2017 14:25:08 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 91805 invoked by uid 99); 27 Sep 2017 14:25:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Sep 2017 14:25:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B1EEE1814D6 for ; Wed, 27 Sep 2017 14:25:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 177-aT9BNbJ2 for ; Wed, 27 Sep 2017 14:25:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 3C88961299 for ; Wed, 27 Sep 2017 14:25:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 5FA42E0012 for ; Wed, 27 Sep 2017 14:41:08 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 3FBD924282 for ; Wed, 27 Sep 2017 14:25:04 +0000 (UTC) Date: Wed, 27 Sep 2017 14:25:04 +0000 (UTC) From: "Lukasz Lenart (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (WW-4862) Default Multipart validation regex is invalid due to charset encoding MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 27 Sep 2017 14:25:10 -0000 [ https://issues.apache.org/jira/browse/WW-4862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Lukasz Lenart updated WW-4862: ------------------------------ Description: 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} was: Struts 2.5.12 introduced a regex matches for multipart requests. Struts 2.5.13 fixed [WW-4818|https://issues.apache.org/jira/browse/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} > 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)