You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robby Pelssers <Ro...@nxp.com> on 2012/06/06 13:09:46 UTC

issue with form encoding C2.2

Hi all,

Just wanted to have a short discussion on an issue that I wasted quite some hours on.  Let me first explain that I configured my cocoon block with following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html :

org.apache.cocoon.containerencoding=UTF-8
org.apache.cocoon.formencoding=UTF-8


Recently I created a form showing pre-populated data from an xquery.  One form field contained the Ohm Ω character and the browser rendered if fine.  But I had to post the data back to the server and the Ohm sign got corrupted.

From firebug I could see following:
descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
magCode             R73
specificationStatus          Product

From flowscript:
descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
specificationStatus=Product
magCode=R73



So next I started looking at cocoon sources using URLDecoder and I had a suspicion that NetUtils might be responsible for the issue. But that didn’t seem to be the issue.  I managed to find out that the value I defined for formencoding is not actually used.  The reason is that it also is set in cocoon-core and either it doesn’t get overwritten or the property from cocoon-core is overwriting my own property value.

nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core
$ find . -name *.properties | xargs grep "formencoding"
./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1

So what’s the best way to fix this?



RE: issue with form encoding C2.2

Posted by Robby Pelssers <Ro...@nxp.com>.
Ivan was simultaneously looking into the issue and he confirms that the name of the property file is responsible for the order in which the property files are loaded as documented on http://cocoon.apache.org/subprojects/configuration/spring-configurator/1310_1_1.html

The classpath is scanned for property files inside jar files located at /META-INF/cocoon/properties/*.properties. Usually these property files are default values for beans distributed with the jar the property files are contained in. All these property files are read in alphabetical order.

So when we rename our property file to zmyblock.properties our value for the formencoding is used instead of the one from core.properties.  And I also know that I can easily solve it by putting the property file in the WEB-INF/cocoon/properties of my webapp block. But that still will not resolve the issue when I want to quickly test a block using maven-jetty-plugin.

Robby

From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
Sent: Wednesday, June 06, 2012 1:37 PM
To: dev@cocoon.apache.org
Subject: RE: issue with form encoding C2.2

One step closer to proving the issue:
The SettingsBeanFactoryPostProcessor.java preInit method reads the properties in order listed below. It is ResourceUtils.java which loads all classpath properties file in the array ‘resources’ as presented below.
As you can see the core.properties file gets loaded at the end overwriting my own property. I think the best solution would be to actually remove that property from core.properties and let the developer decide himself declaring that value.
WDYT?
Robby


 *   resources = {org.springframework.core.io.Resource[15]@5776}
 *   [0] = {org.springframework.core.io.FileSystemResource@5781}"file [C:\\development\\workspaces\\intellij11\\CTPI-PX\\spider2\\vpmigration\\target\\classes\\META-INF\\cocoon\\properties\\cocoon.properties]"
 *   [1] = {org.springframework.core.io.UrlResource@5782}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/cocoon.properties]"
 *   [2] = {org.springframework.core.io.UrlResource@5783}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/jasperreports_extension.properties]"
 *   [3] = {org.springframework.core.io.UrlResource@5784}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/spider.properties]"
 *   [4] = {org.springframework.core.io.UrlResource@5785}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/upload.properties]"
 *   [5] = {org.springframework.core.io.UrlResource@5786}"URL [jar:file:/C:/development/mavenrepository/org/apache/cocoon/cocoon-sitemap-impl/1.0.1/cocoon-sitemap-impl-1.0.1.jar!/META-INF/cocoon/properties/cocoon-core-continuations-manager.properties]"
 *   [6] = {org.springframework.core.io.UrlResource@5787}"URL [jar:file:/C:/development/mavenrepository/org/apache/cocoon/cocoon-core/2.2.0/cocoon-core-2.2.0.jar!/META-INF/cocoon/properties/core.properties]"
 *   [7] = {org.springframework.core.io.UrlResource@5788}"URL [jar:file:/C:/development/mavenrepository/org/apache/cocoon/cocoon-store-impl/1.0.0/cocoon-store-impl-1.0.0.jar!/META-INF/cocoon/properties/cocoon-store-impl.properties]"
 *   [8] = {org.springframework.core.io.UrlResource@5789}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/cocoon.properties]"
 *   [9] = {org.springframework.core.io.UrlResource@5790}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/jasperreports_extension.properties]"
 *   [10] = {org.springframework.core.io.UrlResource@5791}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/spider.properties]"
 *   [11] = {org.springframework.core.io.UrlResource@5792}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/upload.properties]"
 *   [12] = {org.springframework.core.io.UrlResource@5793}"URL [jar:file:/c:/development/mavenrepository/org/apache/cocoon/cocoon-store-impl/1.0.0/cocoon-store-impl-1.0.0.jar!/META-INF/cocoon/properties/cocoon-store-impl.properties]"
 *   [13] = {org.springframework.core.io.UrlResource@5794}"URL [jar:file:/c:/development/mavenrepository/org/apache/cocoon/cocoon-sitemap-impl/1.0.1/cocoon-sitemap-impl-1.0.1.jar!/META-INF/cocoon/properties/cocoon-core-continuations-manager.properties]"
 *   [14] = {org.springframework.core.io.UrlResource@5795}"URL [jar:file:/c:/development/mavenrepository/org/apache/cocoon/cocoon-core/2.2.0/cocoon-core-2.2.0.jar!/META-INF/cocoon/properties/core.properties]"


From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
Sent: Wednesday, June 06, 2012 1:27 PM
To: dev@cocoon.apache.org
Subject: RE: issue with form encoding C2.2

Hi Javier,

I read about default encoding for using GET, but I’m actually ‘posting’ the form.  I really am convinced that the only real issue here is that the formencoding property ‘org.apache.cocoon.formencoding’ is being set with the value from the cocoon-core block.  I’m currently debugging the spring configurator and I suspect this will confirm the issue.  Will get back on this today.

Robby

From: Javier Puerto [mailto:jpuerto@gmail.com]
Sent: Wednesday, June 06, 2012 1:23 PM
To: dev@cocoon.apache.org
Subject: Re: issue with form encoding C2.2

Hi Robby,

Maybe it's helps, by default Tomcat uses ISO-8859-1 for URL encoding so GET parameters will be affected. http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1
We had similar issues before and was fixed configuring the Tomcat connector as UTF-8.

Salu2
2012/6/6 Robby Pelssers <Ro...@nxp.com>>
I did found a workaround by the way…

If you add an extra request parameter called cocoon-form-encoding and set it to utf-8 it will work

Snippet from RequestProcessor.java:

    protected Environment getEnvironment(String uri,
                                         HttpServletRequest req,
                                         HttpServletResponse res)
    throws Exception {

        String formEncoding = req.getParameter("cocoon-form-encoding");
        if (formEncoding == null) {
            formEncoding = this.settings.getFormEncoding();
        }

        HttpEnvironment env;
        env = new HttpEnvironment(uri,
                                  req,
                                  res,
                                  this.servletContext,
                                  this.environmentContext,
                                  this.containerEncoding,
                                  formEncoding);
        return env;
    }

From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com<ma...@nxp.com>]
Sent: Wednesday, June 06, 2012 1:10 PM
To: dev@cocoon.apache.org<ma...@cocoon.apache.org>; users@cocoon.apache.org<ma...@cocoon.apache.org>
Subject: issue with form encoding C2.2

Hi all,

Just wanted to have a short discussion on an issue that I wasted quite some hours on.  Let me first explain that I configured my cocoon block with following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html :

org.apache.cocoon.containerencoding=UTF-8
org.apache.cocoon.formencoding=UTF-8


Recently I created a form showing pre-populated data from an xquery.  One form field contained the Ohm Ω character and the browser rendered if fine.  But I had to post the data back to the server and the Ohm sign got corrupted.

From firebug I could see following:
descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
magCode             R73
specificationStatus          Product

From flowscript:
descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
specificationStatus=Product
magCode=R73



So next I started looking at cocoon sources using URLDecoder and I had a suspicion that NetUtils might be responsible for the issue. But that didn’t seem to be the issue.  I managed to find out that the value I defined for formencoding is not actually used.  The reason is that it also is set in cocoon-core and either it doesn’t get overwritten or the property from cocoon-core is overwriting my own property value.

nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core
$ find . -name *.properties | xargs grep "formencoding"
./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1

So what’s the best way to fix this?




RE: issue with form encoding C2.2

Posted by Robby Pelssers <Ro...@nxp.com>.
One step closer to proving the issue:
The SettingsBeanFactoryPostProcessor.java preInit method reads the properties in order listed below. It is ResourceUtils.java which loads all classpath properties file in the array ‘resources’ as presented below.
As you can see the core.properties file gets loaded at the end overwriting my own property. I think the best solution would be to actually remove that property from core.properties and let the developer decide himself declaring that value.
WDYT?
Robby


 *   resources = {org.springframework.core.io.Resource[15]@5776}
 *   [0] = {org.springframework.core.io.FileSystemResource@5781}"file [C:\\development\\workspaces\\intellij11\\CTPI-PX\\spider2\\vpmigration\\target\\classes\\META-INF\\cocoon\\properties\\cocoon.properties]"
 *   [1] = {org.springframework.core.io.UrlResource@5782}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/cocoon.properties]"
 *   [2] = {org.springframework.core.io.UrlResource@5783}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/jasperreports_extension.properties]"
 *   [3] = {org.springframework.core.io.UrlResource@5784}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/spider.properties]"
 *   [4] = {org.springframework.core.io.UrlResource@5785}"URL [jar:file:/C:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/upload.properties]"
 *   [5] = {org.springframework.core.io.UrlResource@5786}"URL [jar:file:/C:/development/mavenrepository/org/apache/cocoon/cocoon-sitemap-impl/1.0.1/cocoon-sitemap-impl-1.0.1.jar!/META-INF/cocoon/properties/cocoon-core-continuations-manager.properties]"
 *   [6] = {org.springframework.core.io.UrlResource@5787}"URL [jar:file:/C:/development/mavenrepository/org/apache/cocoon/cocoon-core/2.2.0/cocoon-core-2.2.0.jar!/META-INF/cocoon/properties/core.properties]"
 *   [7] = {org.springframework.core.io.UrlResource@5788}"URL [jar:file:/C:/development/mavenrepository/org/apache/cocoon/cocoon-store-impl/1.0.0/cocoon-store-impl-1.0.0.jar!/META-INF/cocoon/properties/cocoon-store-impl.properties]"
 *   [8] = {org.springframework.core.io.UrlResource@5789}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/cocoon.properties]"
 *   [9] = {org.springframework.core.io.UrlResource@5790}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/jasperreports_extension.properties]"
 *   [10] = {org.springframework.core.io.UrlResource@5791}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/spider.properties]"
 *   [11] = {org.springframework.core.io.UrlResource@5792}"URL [jar:file:/c:/development/mavenrepository/com/nxp/spider2/shared/1.0-SNAPSHOT/shared-1.0-SNAPSHOT.jar!/META-INF/cocoon/properties/upload.properties]"
 *   [12] = {org.springframework.core.io.UrlResource@5793}"URL [jar:file:/c:/development/mavenrepository/org/apache/cocoon/cocoon-store-impl/1.0.0/cocoon-store-impl-1.0.0.jar!/META-INF/cocoon/properties/cocoon-store-impl.properties]"
 *   [13] = {org.springframework.core.io.UrlResource@5794}"URL [jar:file:/c:/development/mavenrepository/org/apache/cocoon/cocoon-sitemap-impl/1.0.1/cocoon-sitemap-impl-1.0.1.jar!/META-INF/cocoon/properties/cocoon-core-continuations-manager.properties]"
 *   [14] = {org.springframework.core.io.UrlResource@5795}"URL [jar:file:/c:/development/mavenrepository/org/apache/cocoon/cocoon-core/2.2.0/cocoon-core-2.2.0.jar!/META-INF/cocoon/properties/core.properties]"


From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
Sent: Wednesday, June 06, 2012 1:27 PM
To: dev@cocoon.apache.org
Subject: RE: issue with form encoding C2.2

Hi Javier,

I read about default encoding for using GET, but I’m actually ‘posting’ the form.  I really am convinced that the only real issue here is that the formencoding property ‘org.apache.cocoon.formencoding’ is being set with the value from the cocoon-core block.  I’m currently debugging the spring configurator and I suspect this will confirm the issue.  Will get back on this today.

Robby

From: Javier Puerto [mailto:jpuerto@gmail.com]
Sent: Wednesday, June 06, 2012 1:23 PM
To: dev@cocoon.apache.org
Subject: Re: issue with form encoding C2.2

Hi Robby,

Maybe it's helps, by default Tomcat uses ISO-8859-1 for URL encoding so GET parameters will be affected. http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1
We had similar issues before and was fixed configuring the Tomcat connector as UTF-8.

Salu2
2012/6/6 Robby Pelssers <Ro...@nxp.com>>
I did found a workaround by the way…

If you add an extra request parameter called cocoon-form-encoding and set it to utf-8 it will work

Snippet from RequestProcessor.java:

    protected Environment getEnvironment(String uri,
                                         HttpServletRequest req,
                                         HttpServletResponse res)
    throws Exception {

        String formEncoding = req.getParameter("cocoon-form-encoding");
        if (formEncoding == null) {
            formEncoding = this.settings.getFormEncoding();
        }

        HttpEnvironment env;
        env = new HttpEnvironment(uri,
                                  req,
                                  res,
                                  this.servletContext,
                                  this.environmentContext,
                                  this.containerEncoding,
                                  formEncoding);
        return env;
    }

From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com<ma...@nxp.com>]
Sent: Wednesday, June 06, 2012 1:10 PM
To: dev@cocoon.apache.org<ma...@cocoon.apache.org>; users@cocoon.apache.org<ma...@cocoon.apache.org>
Subject: issue with form encoding C2.2

Hi all,

Just wanted to have a short discussion on an issue that I wasted quite some hours on.  Let me first explain that I configured my cocoon block with following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html :

org.apache.cocoon.containerencoding=UTF-8
org.apache.cocoon.formencoding=UTF-8


Recently I created a form showing pre-populated data from an xquery.  One form field contained the Ohm Ω character and the browser rendered if fine.  But I had to post the data back to the server and the Ohm sign got corrupted.

From firebug I could see following:
descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
magCode             R73
specificationStatus          Product

From flowscript:
descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
specificationStatus=Product
magCode=R73



So next I started looking at cocoon sources using URLDecoder and I had a suspicion that NetUtils might be responsible for the issue. But that didn’t seem to be the issue.  I managed to find out that the value I defined for formencoding is not actually used.  The reason is that it also is set in cocoon-core and either it doesn’t get overwritten or the property from cocoon-core is overwriting my own property value.

nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core
$ find . -name *.properties | xargs grep "formencoding"
./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1

So what’s the best way to fix this?




RE: issue with form encoding C2.2

Posted by Robby Pelssers <Ro...@nxp.com>.
Hi Javier,

I read about default encoding for using GET, but I’m actually ‘posting’ the form.  I really am convinced that the only real issue here is that the formencoding property ‘org.apache.cocoon.formencoding’ is being set with the value from the cocoon-core block.  I’m currently debugging the spring configurator and I suspect this will confirm the issue.  Will get back on this today.

Robby

From: Javier Puerto [mailto:jpuerto@gmail.com]
Sent: Wednesday, June 06, 2012 1:23 PM
To: dev@cocoon.apache.org
Subject: Re: issue with form encoding C2.2

Hi Robby,

Maybe it's helps, by default Tomcat uses ISO-8859-1 for URL encoding so GET parameters will be affected. http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1
We had similar issues before and was fixed configuring the Tomcat connector as UTF-8.

Salu2
2012/6/6 Robby Pelssers <Ro...@nxp.com>>
I did found a workaround by the way…

If you add an extra request parameter called cocoon-form-encoding and set it to utf-8 it will work

Snippet from RequestProcessor.java:

    protected Environment getEnvironment(String uri,
                                         HttpServletRequest req,
                                         HttpServletResponse res)
    throws Exception {

        String formEncoding = req.getParameter("cocoon-form-encoding");
        if (formEncoding == null) {
            formEncoding = this.settings.getFormEncoding();
        }

        HttpEnvironment env;
        env = new HttpEnvironment(uri,
                                  req,
                                  res,
                                  this.servletContext,
                                  this.environmentContext,
                                  this.containerEncoding,
                                  formEncoding);
        return env;
    }

From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com<ma...@nxp.com>]
Sent: Wednesday, June 06, 2012 1:10 PM
To: dev@cocoon.apache.org<ma...@cocoon.apache.org>; users@cocoon.apache.org<ma...@cocoon.apache.org>
Subject: issue with form encoding C2.2

Hi all,

Just wanted to have a short discussion on an issue that I wasted quite some hours on.  Let me first explain that I configured my cocoon block with following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html :

org.apache.cocoon.containerencoding=UTF-8
org.apache.cocoon.formencoding=UTF-8


Recently I created a form showing pre-populated data from an xquery.  One form field contained the Ohm Ω character and the browser rendered if fine.  But I had to post the data back to the server and the Ohm sign got corrupted.

From firebug I could see following:
descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
magCode             R73
specificationStatus          Product

From flowscript:
descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
specificationStatus=Product
magCode=R73



So next I started looking at cocoon sources using URLDecoder and I had a suspicion that NetUtils might be responsible for the issue. But that didn’t seem to be the issue.  I managed to find out that the value I defined for formencoding is not actually used.  The reason is that it also is set in cocoon-core and either it doesn’t get overwritten or the property from cocoon-core is overwriting my own property value.

nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core
$ find . -name *.properties | xargs grep "formencoding"
./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1

So what’s the best way to fix this?




Re: issue with form encoding C2.2

Posted by Javier Puerto <jp...@gmail.com>.
Hi Robby,

Maybe it's helps, by default Tomcat uses ISO-8859-1 for URL encoding so GET
parameters will be affected.
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1
We had similar issues before and was fixed configuring the Tomcat connector
as UTF-8.

Salu2

2012/6/6 Robby Pelssers <Ro...@nxp.com>

> I did found a workaround by the way… ****
>
> ** **
>
> If you add an extra request parameter called cocoon-form-encoding and set
> it to utf-8 it will work ****
>
> ** **
>
> Snippet from RequestProcessor.java:****
>
> ** **
>
>     protected Environment getEnvironment(String uri,****
>
>                                          HttpServletRequest req,****
>
>                                          HttpServletResponse res)****
>
>     throws Exception {****
>
> ** **
>
>         String formEncoding = req.getParameter("cocoon-form-encoding");***
> *
>
>         if (formEncoding == null) {****
>
>             formEncoding = this.settings.getFormEncoding();****
>
>         }****
>
> ** **
>
>         HttpEnvironment env;****
>
>         env = new HttpEnvironment(uri,****
>
>                                   req,****
>
>                                   res,****
>
>                                   this.servletContext,****
>
>                                   this.environmentContext,****
>
>                                   this.containerEncoding,****
>
>                                   formEncoding);****
>
>         return env;****
>
>     }****
>
> ** **
>
> *From:* Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
> *Sent:* Wednesday, June 06, 2012 1:10 PM
> *To:* dev@cocoon.apache.org; users@cocoon.apache.org
> *Subject:* issue with form encoding C2.2****
>
> ** **
>
> Hi all,****
>
> ** **
>
> Just wanted to have a short discussion on an issue that I wasted quite
> some hours on.  Let me first explain that I configured my cocoon block with
> following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html:
> ****
>
> ** **
>
> org.apache.cocoon.containerencoding=UTF-8****
>
> org.apache.cocoon.formencoding=UTF-8****
>
> ** **
>
> ** **
>
> Recently I created a form showing pre-populated data from an xquery.  One
> form field contained the Ohm Ω character and the browser rendered if fine.
> But I had to post the data back to the server and the Ohm sign got
> corrupted.****
>
> ** **
>
> From firebug I could see following:****
>
> descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using
> NextPower technology****
>
> magCode             R73****
>
> specificationStatus          Product****
>
> ** **
>
> From flowscript:****
>
> descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK
> using NextPower technology****
>
> specificationStatus=Product****
>
> magCode=R73****
>
> ** **
>
> ** **
>
> ** **
>
> So next I started looking at cocoon sources using URLDecoder and I had a
> suspicion that NetUtils might be responsible for the issue. But that didn’t
> seem to be the issue.  I managed to find out that the value I defined for
> formencoding is not actually used.  The reason is that it also is set in
> cocoon-core and either it doesn’t get overwritten or the property from
> cocoon-core is overwriting my own property value.****
>
> ** **
>
> nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core****
>
> $ find . -name *.properties | xargs grep "formencoding"****
>
>
> ./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1
> ****
>
> ** **
>
> So what’s the best way to fix this?  ****
>
> ** **
>
> ** **
>

RE: issue with form encoding C2.2

Posted by Robby Pelssers <Ro...@nxp.com>.
I did found a workaround by the way…

If you add an extra request parameter called cocoon-form-encoding and set it to utf-8 it will work

Snippet from RequestProcessor.java:

    protected Environment getEnvironment(String uri,
                                         HttpServletRequest req,
                                         HttpServletResponse res)
    throws Exception {

        String formEncoding = req.getParameter("cocoon-form-encoding");
        if (formEncoding == null) {
            formEncoding = this.settings.getFormEncoding();
        }

        HttpEnvironment env;
        env = new HttpEnvironment(uri,
                                  req,
                                  res,
                                  this.servletContext,
                                  this.environmentContext,
                                  this.containerEncoding,
                                  formEncoding);
        return env;
    }

From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
Sent: Wednesday, June 06, 2012 1:10 PM
To: dev@cocoon.apache.org; users@cocoon.apache.org
Subject: issue with form encoding C2.2

Hi all,

Just wanted to have a short discussion on an issue that I wasted quite some hours on.  Let me first explain that I configured my cocoon block with following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html :

org.apache.cocoon.containerencoding=UTF-8
org.apache.cocoon.formencoding=UTF-8


Recently I created a form showing pre-populated data from an xquery.  One form field contained the Ohm Ω character and the browser rendered if fine.  But I had to post the data back to the server and the Ohm sign got corrupted.

From firebug I could see following:
descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
magCode             R73
specificationStatus          Product

From flowscript:
descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
specificationStatus=Product
magCode=R73



So next I started looking at cocoon sources using URLDecoder and I had a suspicion that NetUtils might be responsible for the issue. But that didn’t seem to be the issue.  I managed to find out that the value I defined for formencoding is not actually used.  The reason is that it also is set in cocoon-core and either it doesn’t get overwritten or the property from cocoon-core is overwriting my own property value.

nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core
$ find . -name *.properties | xargs grep "formencoding"
./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1

So what’s the best way to fix this?



RE: issue with form encoding C2.2

Posted by Robby Pelssers <Ro...@nxp.com>.
I did found a workaround by the way…

If you add an extra request parameter called cocoon-form-encoding and set it to utf-8 it will work

Snippet from RequestProcessor.java:

    protected Environment getEnvironment(String uri,
                                         HttpServletRequest req,
                                         HttpServletResponse res)
    throws Exception {

        String formEncoding = req.getParameter("cocoon-form-encoding");
        if (formEncoding == null) {
            formEncoding = this.settings.getFormEncoding();
        }

        HttpEnvironment env;
        env = new HttpEnvironment(uri,
                                  req,
                                  res,
                                  this.servletContext,
                                  this.environmentContext,
                                  this.containerEncoding,
                                  formEncoding);
        return env;
    }

From: Robby Pelssers [mailto:Robby.Pelssers@nxp.com]
Sent: Wednesday, June 06, 2012 1:10 PM
To: dev@cocoon.apache.org; users@cocoon.apache.org
Subject: issue with form encoding C2.2

Hi all,

Just wanted to have a short discussion on an issue that I wasted quite some hours on.  Let me first explain that I configured my cocoon block with following two properties as per http://cocoon.apache.org/2.2/1366_1_1.html :

org.apache.cocoon.containerencoding=UTF-8
org.apache.cocoon.formencoding=UTF-8


Recently I created a form showing pre-populated data from an xquery.  One form field contained the Ohm Ω character and the browser rendered if fine.  But I had to post the data back to the server and the Ohm sign got corrupted.

From firebug I could see following:
descriptiveTitle N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
magCode             R73
specificationStatus          Product

From flowscript:
descriptiveTitle=N-channel 25 V 2.85 mΩ logic level MOSFET in LFPAK using NextPower technology
specificationStatus=Product
magCode=R73



So next I started looking at cocoon sources using URLDecoder and I had a suspicion that NetUtils might be responsible for the issue. But that didn’t seem to be the issue.  I managed to find out that the value I defined for formencoding is not actually used.  The reason is that it also is set in cocoon-core and either it doesn’t get overwritten or the property from cocoon-core is overwriting my own property value.

nxp10009@NXL01262 /c/development/workspaces/cocoon22/trunk/core
$ find . -name *.properties | xargs grep "formencoding"
./cocoon-core/src/main/resources/META-INF/cocoon/properties/core.properties:org.apache.cocoon.formencoding=ISO-8859-1

So what’s the best way to fix this?