From 09a1f44eb182c83b02bf610f288a32c3eb3dd71b Mon Sep 17 00:00:00 2001 From: kkolinko Date: Mon, 21 Dec 2009 06:29:40 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@892707 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/tomcat/util/http/HttpMessages.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/java/org/apache/tomcat/util/http/HttpMessages.java b/java/org/apache/tomcat/util/http/HttpMessages.java index 9e56679fa..8abb5c15a 100644 --- a/java/org/apache/tomcat/util/http/HttpMessages.java +++ b/java/org/apache/tomcat/util/http/HttpMessages.java @@ -118,16 +118,21 @@ public class HttpMessages { if (msg == null) { return true; } - - // TEXT is defined as OCTET excpet CTLs + + // Reason-Phrase is defined as * + // 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; } } -- 2.11.0