You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ryan Lubke <Ry...@Sun.COM> on 2002/03/27 16:20:41 UTC

[Fwd: [PATCH] TC 4.0/Coyote locale parsing issue]

Did some checking and the TC 4.0 HTTP/1.1 and HTTP/1.0 connectors have
the same problem (o.a.c.c.http and o.a.c.c.http10).

I've modified the connectors in question and ran the same set of tests
that I ran against Coyote and all seems well.  Locales with variants are
properly handled.

I've attached patches for all 3 connectors.

-rl

-----Forwarded Message-----

From: Ryan Lubke <Ry...@Sun.COM>
To: tcdev <to...@jakarta.apache.org>
Subject: [PATCH] TC 4.0/Coyote locale parsing issue
Date: 25 Mar 2002 13:35:28 -0500

Hi,

When dealing with preferred locales from a client (Accept-Language), 
the CoyoteRequest class (org.apache.coyote.tomcat4) doesn't correctly
handle locales with variants (i.e. en-IE-EURO).
RFC 2616 states that the following for language-range of
Accept-Language:  
  language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )

So it seems that variants coming in from a client are legal (provided
I've read the BNF properly)

The attached patch seems to correct the issue.

-rl


----


Index: CoyoteRequest.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v
retrieving revision 1.11
diff -u -r1.11 CoyoteRequest.java
--- CoyoteRequest.java	19 Mar 2002 20:34:41 -0000	1.11
+++ CoyoteRequest.java	25 Mar 2002 14:34:54 -0000
@@ -1987,17 +1987,27 @@
             // Extract the language and country for this entry
             String language = null;
             String country = null;
+            String variant = null;
             int dash = entry.indexOf('-');
             if (dash < 0) {
                 language = entry;
                 country = "";
+                variant = "";
             } else {
                 language = entry.substring(0, dash);
                 country = entry.substring(dash + 1);
+                int vDash = country.indexOf('-');
+                if (vDash > 0) {
+                    String cTemp = country.substring(0, vDash);
+                    variant = country.substring(vDash + 1);
+                    country = cTemp;
+                } else {
+                    variant = "";
+                }
             }
 
             // Add a new Locale to the list of Locales for this quality level
-            Locale locale = new Locale(language, country);
+            Locale locale = new Locale(language, country, variant);
             Double key = new Double(-quality);  // Reverse the order
             ArrayList values = (ArrayList) locales.get(key);
             if (values == null) {

----


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>