Would you like to toss this into T2.4 as a valve?  It might be the perfect
way for you start familiarizing and providing feedback on 2.4!

Is this class (from Scarab) basically like what you are thinking of:
http://scarab.tigris.org/source/browse/scarab/src/java/org/tigris/scarab/pip
eline/DetermineCharsetValve.java

Eric

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 08, 2004 11:18 PM
> To: [EMAIL PROTECTED]
> Subject: cvs commit:
> jakarta-turbine-2/src/java/org/apache/turbine/util/parser
> BaseValueParser.java DefaultParameterParser.java
>
>
> henning     2004/11/08 14:17:44
>
>   Modified:    conf     Tag: TURBINE_2_3_BRANCH
> TurbineResources.properties
>                src/java/org/apache/turbine Tag: TURBINE_2_3_BRANCH
>                         Turbine.java TurbineConstants.java
>                src/java/org/apache/turbine/util/parser Tag:
>                         TURBINE_2_3_BRANCH BaseValueParser.java
>                         DefaultParameterParser.java
>   Log:
>   One of the really scary "how could this ever work without?" patches.
>
>   This allows the application to define the default content encoding of
>   incoming requests. Which in turn allows an all-UTF-8 application to
>   declare the POST forms to contain UTF-8 chars and keep all the special
>   characters alive.
>
>   Hint: If you ever wanted to chase a red herring, try this with a
>   RequestDumperValve in Tomcat...
>
>   Default encoding is ISO-8859-1, which is an improvement over the
>   Turbine 2.3.x US-ASCII, but this patch really shines in connection
>   with UTF-8.
>
>   Definitely more testing with other containers besides Tomcat 5.0.x
>   wanted! req.setCharacterEncoding() is not the most stable method in
>   the various web containers.
>
>   (The functionality of this patch would be a perfect match for a Valve
>   in the Pipeline. This valve would be the first thing in the pipeline
>   and set the CharacterEncoding of the incoming request).
>
>   Revision  Changes    Path
>   No                   revision
>   No                   revision
>   1.51.2.1  +7 -1      jakarta-turbine-2/conf/TurbineResources.properties
>
>   Index: TurbineResources.properties
>   ===================================================================
>   RCS file: /home/cvs/jakarta-turbine-2/conf/TurbineResources.properties,v
>   retrieving revision 1.51
>   retrieving revision 1.51.2.1
>   diff -u -r1.51 -r1.51.2.1
>   --- TurbineResources.properties     2 Sep 2003 13:28:28 -0000       1.51
>   +++ TurbineResources.properties     8 Nov 2004 22:17:43 -0000
> 1.51.2.1
>   @@ -217,6 +217,12 @@
>    #
>    action.eventsubmit.needsvalue = false
>
>   +# If the web container does not supply an explicit encoding for the
>   +# request data, assume that is has this encoding. If you use e.g.
>   +# UTF-8 or ISO-8859-<something>, change this parameter to keep your
>   +# special characters. Default is ISO-8859-1
>   +input.encoding = ISO-8859-1
>   +
>    # -------------------------------------------------------------------
>    #
>    #  J N D I  C O N T E X T S
>
>
>
>   No                   revision
>   No                   revision
>   1.45.2.4  +36 -1
> jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java
>
>   Index: Turbine.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java,v
>   retrieving revision 1.45.2.3
>   retrieving revision 1.45.2.4
>   diff -u -r1.45.2.3 -r1.45.2.4
>   --- Turbine.java    16 Aug 2004 23:31:59 -0000      1.45.2.3
>   +++ Turbine.java    8 Nov 2004 22:17:43 -0000       1.45.2.4
>   @@ -20,6 +20,8 @@
>    import java.io.FileInputStream;
>    import java.io.FileNotFoundException;
>    import java.io.IOException;
>   +import java.io.UnsupportedEncodingException;
>   +
>    import java.util.Properties;
>
>    import javax.servlet.ServletConfig;
>   @@ -157,6 +159,9 @@
>        /** A reference to the RunData Service */
>        private RunDataService rundataService = null;
>
>   +    /** Default Input encoding if the servlet container does
> not report an encoding */
>   +    private String inputEncoding = null;
>   +
>        /** Logging class from commons.logging */
>        private static Log log = LogFactory.getLog(Turbine.class);
>
>   @@ -376,6 +381,16 @@
>            // a value of 'true' will be started when
>            // the service manager is initialized.
>            getServiceManager().init();
>   +
>   +        // Get the default input encoding
>   +        inputEncoding = configuration.getString(
>   +                TurbineConstants.PARAMETER_ENCODING_KEY,
>   +                TurbineConstants.PARAMETER_ENCODING_DEFAULT);
>   +
>   +        if (log.isDebugEnabled())
>   +        {
>   +            log.debug("Input Encoding has been set to " +
> inputEncoding);
>   +        }
>        }
>
>        /**
>   @@ -640,6 +655,26 @@
>                if (initFailure != null)
>                {
>                    throw initFailure;
>   +            }
>   +
>   +            //
>   +            // If the servlet container gives us no clear
> indication about the
>   +            // Encoding of the contents, set it to our default value.
>   +            if (req.getCharacterEncoding() == null)
>   +            {
>   +                if (log.isDebugEnabled())
>   +                {
>   +                    log.debug("Changing Input Encoding to " +
> inputEncoding);
>   +                }
>   +
>   +                try
>   +                {
>   +                    req.setCharacterEncoding(inputEncoding);
>   +                }
>   +                catch (UnsupportedEncodingException uee)
>   +                {
>   +                    log.warn("Could not change request
> encoding to " + inputEncoding, uee);
>   +                }
>                }
>
>                // Get general RunData here...
>
>
>
>   1.26.2.3  +7 -1
> jakarta-turbine-2/src/java/org/apache/turbine/TurbineConstants.java
>
>   Index: TurbineConstants.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/TurbineCon
> stants.java,v
>   retrieving revision 1.26.2.2
>   retrieving revision 1.26.2.3
>   diff -u -r1.26.2.2 -r1.26.2.3
>   --- TurbineConstants.java   20 May 2004 03:03:54 -0000      1.26.2.2
>   +++ TurbineConstants.java   8 Nov 2004 22:17:44 -0000       1.26.2.3
>   @@ -318,4 +318,10 @@
>
>        /** Prefix for scheduler job related classes */
>        String SCHEDULEDJOB_PREFIX = "scheduledjobs";
>   +
>   +    /** Encoding for Parameter Parser */
>   +    String PARAMETER_ENCODING_KEY = "input.encoding";
>   +
>   +    /** Default Encoding for Parameter Parser */
>   +    String PARAMETER_ENCODING_DEFAULT = "ISO-8859-1";
>    }
>
>
>
>   No                   revision
>   No                   revision
>   1.23.2.3  +4 -3
> jakarta-turbine-2/src/java/org/apache/turbine/util/parser/BaseValu
> eParser.java
>
>   Index: BaseValueParser.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/parse
> r/BaseValueParser.java,v
>   retrieving revision 1.23.2.2
>   retrieving revision 1.23.2.3
>   diff -u -r1.23.2.2 -r1.23.2.3
>   --- BaseValueParser.java    20 May 2004 03:33:43 -0000      1.23.2.2
>   +++ BaseValueParser.java    8 Nov 2004 22:17:44 -0000       1.23.2.3
>   @@ -47,6 +47,7 @@
>    import org.apache.torque.om.NumberKey;
>    import org.apache.torque.om.StringKey;
>
>   +import org.apache.turbine.TurbineConstants;
>    import org.apache.turbine.util.DateSelector;
>    import org.apache.turbine.util.TimeSelector;
>    import org.apache.turbine.util.pool.Recyclable;
>   @@ -97,7 +98,7 @@
>        private Map parameters = new HashMap();
>
>        /** The character encoding to use when converting to byte arrays */
>   -    private String characterEncoding = "US-ASCII";
>   +    private String characterEncoding =
> TurbineConstants.PARAMETER_ENCODING_DEFAULT;
>
>        /**
>         * A static version of the convert method, which
>   @@ -136,7 +137,7 @@
>         */
>        public void recycle()
>        {
>   -        recycle("US-ASCII");
>   +        recycle(TurbineConstants.PARAMETER_ENCODING_DEFAULT);
>        }
>
>        /**
>
>
>
>   1.20.2.3  +5 -4
> jakarta-turbine-2/src/java/org/apache/turbine/util/parser/DefaultP
> arameterParser.java
>
>   Index: DefaultParameterParser.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/parse
> r/DefaultParameterParser.java,v
>   retrieving revision 1.20.2.2
>   retrieving revision 1.20.2.3
>   diff -u -r1.20.2.2 -r1.20.2.3
>   --- DefaultParameterParser.java     20 May 2004 03:33:43 -0000
> 1.20.2.2
>   +++ DefaultParameterParser.java     8 Nov 2004 22:17:44 -0000
> 1.20.2.3
>   @@ -27,13 +27,12 @@
>    import javax.servlet.http.HttpServletRequest;
>
>    import org.apache.commons.fileupload.FileItem;
>   -
>    import org.apache.commons.logging.Log;
>    import org.apache.commons.logging.LogFactory;
>
>   +import org.apache.turbine.TurbineConstants;
>    import org.apache.turbine.services.upload.TurbineUpload;
>    import org.apache.turbine.services.upload.UploadService;
>   -
>    import org.apache.turbine.util.TurbineException;
>    import org.apache.turbine.util.pool.Recyclable;
>
>   @@ -169,7 +168,9 @@
>            uploadData = null;
>
>            String enc = request.getCharacterEncoding();
>   -        setCharacterEncoding(enc != null ? enc : "US-ASCII");
>   +        setCharacterEncoding(enc != null
>   +                ? enc
>   +                : TurbineConstants.PARAMETER_ENCODING_DEFAULT);
>
>            // String object re-use at its best.
>            String tmp = null;
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to