You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Tamás Buresch (JIRA)" <ji...@apache.org> on 2006/09/11 19:11:22 UTC
[jira] Created: (COCOON-1917) Request Encoding problem:
multipart/form vs. url encoded
Request Encoding problem: multipart/form vs. url encoded
--------------------------------------------------------
Key: COCOON-1917
URL: http://issues.apache.org/jira/browse/COCOON-1917
Project: Cocoon
Issue Type: Bug
Components: * Cocoon Core
Affects Versions: 2.1.8
Reporter: Tamás Buresch
Although this bug was found in Cocoon 2.1.6., seems it is still present in 2.1.8. (by comparing the source files)
Request parameters can be url-encoded (GET) or 'multipart/form' encoded (HTTP POST and form encoding is set to multipart/form).
Cocoon decodes them differently, thus there are problems when HTML is encoded in UTF-8.
Reproducing the bug:
Create a simple xsp or action which dumps the request parameters.
Set the form encoding to UTF-8 and the container encoding to ISO-8859-1 in web.xml.
<init-param>
<param-name>container-encoding</param-name>
<param-value>ISO-8859-1</param-value>
</init-param>
<init-param>
<param-name>form-encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
Use the following HTML fragment.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></HEAD>
<BODY>
<FORM name="x" action="yourcocoon.html" method="post" enctype="multipart/form-data">
<INPUT type="text" name="utfText">
<INPUT type="submit">
</BODY></HTML>
Fill the form with characters having funny accents.
Trying POST and GET yields different results.
GET works, POST fails.
If the container encoding is set to UTF-8, then GET fails but POST works.
Here is a simple patch which partially fixes this bug.
In org\apache\cocoon\environment\http\HttpEnvironment.java the line:
this.request.setContainerEncoding(containerEncoding);
should be replaced with:
// !!! THIS IS JUST A PARTIAL FIX !!!
// The containerEncoding is irrelevant in case of MultipartHttpServletRequest.
// This fix assumes that the client does not send the encoding information to
// the server in case of multipart/form or it is equals to defaultFormEncoding.
//
// Complete fix would be:
// The encoding used in RequestFactory.getServletRequest() is passed to MultipartHttpServletRequest
// and here that encoding is passed to this.request.setContainerEncoding().
//
if (req instanceof MultipartHttpServletRequest) {
this.request.setContainerEncoding(defaultFormEncoding);
} else {
this.request.setContainerEncoding(containerEncoding);
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira