- Based on Mark's patch. Ensure accept-language header conforms to RFC 2616 when...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Dec 2006 01:37:24 +0000 (01:37 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Dec 2006 01:37:24 +0000 (01:37 +0000)
  getLocale and friends, and ignore it if it doesn't.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@483769 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/Request.java

index 2c22bac..33a3436 100644 (file)
@@ -2566,6 +2566,9 @@ public class Request
                     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 @@ public class Request
 
     }
 
+    
+    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;
+    }
+    
 }