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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to