Hi Andreas,
Many thanks for your interest.
Here is the diff, I hope it helps. I am a little bit behind the latest
update, I hope that does not cause you any problems.
regards Jeremy
Index: src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
===================================================================
--- src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
(revision 637948)
+++ src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
(working copy)
@@ -75,8 +75,14 @@
super(uri, null, root, null);
this.request = new HttpRequest(req, this);
- this.request.setCharacterEncoding(defaultFormEncoding);
- this.request.setContainerEncoding(containerEncoding);
+
+ if (req.getCharacterEncoding() == null) { // use the value
from web.xml
+ this.request.setContainerEncoding(containerEncoding !=
null ? containerEncoding : "ISO-8859-1");
+ } else { // use what we have been given
+
this.request.setContainerEncoding(req.getCharacterEncoding());
+ }
+ this.request.setCharacterEncoding(defaultFormEncoding !=
null ? defaultFormEncoding : "UTF-8");
+
this.response = new HttpResponse(res);
this.webcontext = context;
Index: src/java/org/apache/cocoon/environment/http/HttpRequest.java
===================================================================
--- src/java/org/apache/cocoon/environment/http/HttpRequest.java
(revision 637948)
+++ src/java/org/apache/cocoon/environment/http/HttpRequest.java
(working copy)
@@ -316,23 +316,17 @@
public String getParameter(String name) {
String value = this.req.getParameter(name);
- if (this.form_encoding == null || this.container_encoding ==
null || value == null) {
- return value;
+ if (!this.container_encoding.equals(this.form_encoding)) {
+ value = decode(value);
}
- // Form and container encoding are equal, skip expensive
value decoding
- if (this.container_encoding.equals(this.form_encoding)) {
- return value;
- }
- return decode(value);
+ return value;
}
private String decode(String str) {
if (str == null) return null;
try {
- if (this.container_encoding == null)
- this.container_encoding = "ISO-8859-1";
byte[] bytes = str.getBytes(this.container_encoding);
- return new String(bytes, form_encoding);
+ return new String(bytes, this.form_encoding);
} catch (UnsupportedEncodingException uee) {
throw new CascadingRuntimeException("Unsupported
Encoding Exception", uee);
}
@@ -345,7 +339,7 @@
public String[] getParameterValues(String name) {
String[] values = this.req.getParameterValues(name);
if (values == null) return null;
- if (this.form_encoding == null) {
+ if (this.container_encoding.equals(this.form_encoding)) {
return values;
}
String[] decoded_values = new String[values.length];
On 23 Jul 2008, at 23:18, Andreas Hartmann wrote:
Hi Jeremy,
Jeremy Quinn schrieb:
[…]
But I have a solution I think :)
do you have the time to provide a patch with your changes for the
2.1.x branch? We're currently facing encoding problems [1] with Dojo
in Lenya, and I can imagine that your proposal might fix them.
Setting both container encoding and form encoding to utf-8 and
setting the Content-Type header in Dojo [2] seems to work with
Jetty, Firefox 3 and Safari, but I'm not sure about any side effects.
I'll be on vacation for the next two weeks, but maybe someone else
from the Lenya community is willing to do the testing.