tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r483769 - /tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java
Date Fri, 08 Dec 2006 01:37:26 GMT
Author: remm
Date: Thu Dec  7 17:37:24 2006
New Revision: 483769

URL: http://svn.apache.org/viewvc?view=rev&rev=483769
Log:
- Based on Mark's patch. Ensure accept-language header conforms to RFC 2616 when accessed
through 
  getLocale and friends, and ignore it if it doesn't.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java?view=diff&rev=483769&r1=483768&r2=483769
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/connector/Request.java Thu Dec  7 17:37:24
2006
@@ -2566,6 +2566,9 @@
                     variant = "";
                 }
             }
+            if (!isAlpha(language) || !isAlpha(country) || !isAlpha(variant)) {
+                continue;
+            }
 
             // Add a new Locale to the list of Locales for this quality level
             Locale locale = new Locale(language, country, variant);
@@ -2594,4 +2597,15 @@
 
     }
 
+    
+    protected static final boolean isAlpha(String value) {
+        for (int i = 0; i < value.length(); i++) {
+            char c = value.charAt(i);
+            if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <=
'Z') || (c >= '1' && c <= '9'))) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message