Author: kkolinko
Date: Mon Dec 21 06:29:40 2009
New Revision: 892707

URL: http://svn.apache.org/viewvc?rev=892707&view=rev
Log:
Followup for rev.892612
Better fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=47963
Tab character is also allowed in the reason-phrase
Also, use more traditional method of iterating over a string.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/http/HttpMessages.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/http/HttpMessages.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/HttpMessages.java?rev=892707&r1=892706&r2=892707&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/HttpMessages.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/HttpMessages.java Mon Dec 21 
06:29:40 2009
@@ -118,16 +118,21 @@
         if (msg == null) {
             return true;
         }
-        
-        // TEXT is defined as OCTET excpet CTLs
+
+        // Reason-Phrase is defined as *<TEXT, excluding CR, LF>
+        // TEXT is defined as any OCTET except CTLs, but including LWS
         // OCTET is defined as an 8-bit sequence of data
         // CTL is defined as octets 0-31 and 127
-        for (char c : msg.toCharArray()) {
-            if (c > 255 || c < 32 || c == 127) {
-                return false;
+        // LWS, if we exclude CR LF pairs, is defined as SP or HT (32, 9)
+        final int len = msg.length();
+        for (int i = 0; i < len; i++) {
+            char c = msg.charAt(i);
+            if (32 <= c && c <= 126 || 128 <= c && c <= 255 || c == 9) {
+                continue;
             }
+            return false;
         }
-        
+
         return true;
     }
 }



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

Reply via email to