https://issues.apache.org/bugzilla/show_bug.cgi?id=48892

           Summary: Use URIEncoding from server.xml for decoding post data
                    sent with application/x-www-form-urlencoded mime type
           Product: Tomcat 7
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connectors
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: e...@omikron.net


Here is a simple scenario. I have a HTML page served by tomcat with
"Content-Type: text/html;charset=utf-8":

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form method="POST" action="test.jsp" accept-charset="utf-8" method="post"
enctype="application/x-www-form-urlencoded" >
    <input type="text" name="P"/>
    <input type="submit" value="subMit"/>
</form>
</body>
</html>

When this form is submitted the browser will encode the value of the input
field using UTF-8. It will create a POST request header with a content type
line like this:
Content-Type: application/x-www-form-urlencoded

I checked this behavior using FF3.6 and IE8. Both browsers will omit the
charset param in the Content-Type header.

When parsing this request Tomcat will try to get the encoding from the content
type header line (org.apache.coyote.Request.getCharacterEncoding()). Since
there is no charset param in the content type header, Tomcat will use the
standard encoding ISO-8859-1
(org.apache.catalina.connector.Request.parseParameters()). Which is obviously
wrong in this case.

There is no way to force the browser to put the charset in the content type
header
(http://stackoverflow.com/questions/2418944/how-to-force-browser-to-set-charset-in-content-type-http-header).

A good solution for this problem would be to use the URIEncoding connector
setting for application/x-www-form-urlencoded encoded post requests. After all
the encoding names says "URLencoded".

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to