Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 22467 invoked from network); 24 Jul 2008 09:40:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Jul 2008 09:40:45 -0000 Received: (qmail 10485 invoked by uid 500); 24 Jul 2008 09:40:43 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 10397 invoked by uid 500); 24 Jul 2008 09:40:43 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 10386 invoked by uid 99); 24 Jul 2008 09:40:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jul 2008 02:40:43 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [193.201.200.50] (HELO jet.mythic-beasts.com) (193.201.200.50) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jul 2008 09:39:48 +0000 Received: from 87-194-223-167.bethere.co.uk ([87.194.223.167] helo=[192.168.1.76]) by jet.mythic-beasts.com with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.63) (envelope-from ) id 1KLxIv-0003xr-9o for dev@cocoon.apache.org; Thu, 24 Jul 2008 10:40:12 +0100 Message-Id: <2136C260-66BD-4123-A1FF-B4AAA59D0EB2@apache.org> From: Jeremy Quinn To: dev@cocoon.apache.org In-Reply-To: Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v926) Subject: Re: request encoding conundrum Date: Thu, 24 Jul 2008 10:40:01 +0100 References: <7A71D862-E40E-4DC9-A816-8193BBF97023@apache.org> X-Mailer: Apple Mail (2.926) Received-SPF: none (jet.mythic-beasts.com: domain of jeremy@apache.org does not designate permitted sender hosts) client-ip=87.194.223.167 envelope-from=jeremy@apache.org helo=[192.168.1.76] X-BlackCat-Spam-Score: 2 X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=0.2 Hi Andreas, Many thanks for your interest. Here is the diff, I hope it helps. I am a little bit behind the latest =20= update, I hope that does not cause you any problems. regards Jeremy Index: src/java/org/apache/cocoon/environment/http/HttpEnvironment.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/java/org/apache/cocoon/environment/http/HttpEnvironment.java =20= (revision 637948) +++ src/java/org/apache/cocoon/environment/http/HttpEnvironment.java =20= (working copy) @@ -75,8 +75,14 @@ super(uri, null, root, null); this.request =3D new HttpRequest(req, this); - this.request.setCharacterEncoding(defaultFormEncoding); - this.request.setContainerEncoding(containerEncoding); + + if (req.getCharacterEncoding() =3D=3D null) { // use the value =20= from web.xml + this.request.setContainerEncoding(containerEncoding !=3D =20= null ? containerEncoding : "ISO-8859-1"); + } else { // use what we have been given + =20 this.request.setContainerEncoding(req.getCharacterEncoding()); + } + this.request.setCharacterEncoding(defaultFormEncoding !=3D =20 null ? defaultFormEncoding : "UTF-8"); + this.response =3D new HttpResponse(res); this.webcontext =3D context; Index: src/java/org/apache/cocoon/environment/http/HttpRequest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/java/org/apache/cocoon/environment/http/HttpRequest.java =20= (revision 637948) +++ src/java/org/apache/cocoon/environment/http/HttpRequest.java =20= (working copy) @@ -316,23 +316,17 @@ public String getParameter(String name) { String value =3D this.req.getParameter(name); - if (this.form_encoding =3D=3D null || this.container_encoding = =3D=3D =20 null || value =3D=3D null) { - return value; + if (!this.container_encoding.equals(this.form_encoding)) { + value =3D decode(value); } - // Form and container encoding are equal, skip expensive =20 value decoding - if (this.container_encoding.equals(this.form_encoding)) { - return value; - } - return decode(value); + return value; } private String decode(String str) { if (str =3D=3D null) return null; try { - if (this.container_encoding =3D=3D null) - this.container_encoding =3D "ISO-8859-1"; byte[] bytes =3D 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 =20 Encoding Exception", uee); } @@ -345,7 +339,7 @@ public String[] getParameterValues(String name) { String[] values =3D this.req.getParameterValues(name); if (values =3D=3D null) return null; - if (this.form_encoding =3D=3D null) { + if (this.container_encoding.equals(this.form_encoding)) { return values; } String[] decoded_values =3D new String[values.length]; On 23 Jul 2008, at 23:18, Andreas Hartmann wrote: > Hi Jeremy, > > Jeremy Quinn schrieb: > > [=85] > >> But I have a solution I think :) > > do you have the time to provide a patch with your changes for the =20 > 2.1.x branch? We're currently facing encoding problems [1] with Dojo =20= > in Lenya, and I can imagine that your proposal might fix them. =20 > Setting both container encoding and form encoding to utf-8 and =20 > setting the Content-Type header in Dojo [2] seems to work with =20 > 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 =20 > from the Lenya community is willing to do the testing.