Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 13133 invoked from network); 19 May 2008 20:07:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 May 2008 20:07:49 -0000 Received: (qmail 12426 invoked by uid 500); 19 May 2008 20:07:46 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 12354 invoked by uid 500); 19 May 2008 20:07:45 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 12343 invoked by uid 500); 19 May 2008 20:07:45 -0000 Delivered-To: apmail-jakarta-tomcat-dev@jakarta.apache.org Received: (qmail 12340 invoked by uid 99); 19 May 2008 20:07:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 May 2008 13:07:45 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 May 2008 20:06:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E9E6F238899B; Mon, 19 May 2008 13:07:20 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r657954 - in /tomcat/trunk/java/org/apache/coyote/http11: InternalAprInputBuffer.java InternalInputBuffer.java InternalNioInputBuffer.java Date: Mon, 19 May 2008 20:07:20 -0000 To: tomcat-dev@jakarta.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080519200720.E9E6F238899B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Mon May 19 13:07:20 2008 New Revision: 657954 URL: http://svn.apache.org/viewvc?rev=657954&view=rev Log: Note: This patch is on the critical path. Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42750 Making parsing of the request line tolerant of multiple SP and/or HT rather than requiring single SP characters. Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java?rev=657954&r1=657953&r2=657954&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java Mon May 19 13:07:20 2008 @@ -403,7 +403,8 @@ throw new EOFException(sm.getString("iib.eof.error")); } - if (buf[pos] == Constants.SP) { + // Spec says single SP but it also says be tolerant of HT + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { space = true; request.method().setBytes(buf, start, pos - start); } @@ -412,6 +413,20 @@ } + // Spec says single SP but also says be tolerant of multiple and/or HT + while (space) { + // Read new bytes if needed + if (pos >= lastValid) { + if (!fill()) + throw new EOFException(sm.getString("iib.eof.error")); + } + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { + pos++; + } else { + space = false; + } + } + // Mark the current buffer position start = pos; int end = 0; @@ -421,7 +436,6 @@ // Reading the URI // - space = false; boolean eol = false; while (!space) { @@ -432,7 +446,8 @@ throw new EOFException(sm.getString("iib.eof.error")); } - if (buf[pos] == Constants.SP) { + // Spec says single SP but it also says be tolerant of HT + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { space = true; end = pos; } else if ((buf[pos] == Constants.CR) @@ -459,6 +474,21 @@ request.requestURI().setBytes(buf, start, end - start); } + // Spec says single SP but also says be tolerant of multiple and/or HT + while (space) { + // Read new bytes if needed + if (pos >= lastValid) { + if (!fill()) + throw new EOFException(sm.getString("iib.eof.error")); + } + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { + pos++; + } else { + space = false; + } + } + + // Mark the current buffer position start = pos; end = 0; Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java?rev=657954&r1=657953&r2=657954&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/InternalInputBuffer.java Mon May 19 13:07:20 2008 @@ -391,7 +391,8 @@ throw new EOFException(sm.getString("iib.eof.error")); } - if (buf[pos] == Constants.SP) { + // Spec says single SP but it also says be tolerant of HT + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { space = true; request.method().setBytes(buf, start, pos - start); } @@ -400,6 +401,21 @@ } + + // Spec says single SP but also says be tolerant of multiple and/or HT + while (space) { + // Read new bytes if needed + if (pos >= lastValid) { + if (!fill()) + throw new EOFException(sm.getString("iib.eof.error")); + } + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { + pos++; + } else { + space = false; + } + } + // Mark the current buffer position start = pos; int end = 0; @@ -409,7 +425,6 @@ // Reading the URI // - space = false; boolean eol = false; while (!space) { @@ -420,7 +435,8 @@ throw new EOFException(sm.getString("iib.eof.error")); } - if (buf[pos] == Constants.SP) { + // Spec says single SP but it also says be tolerant of HT + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { space = true; end = pos; } else if ((buf[pos] == Constants.CR) @@ -447,6 +463,20 @@ request.requestURI().setBytes(buf, start, end - start); } + // Spec says single SP but also says be tolerant of multiple and/or HT + while (space) { + // Read new bytes if needed + if (pos >= lastValid) { + if (!fill()) + throw new EOFException(sm.getString("iib.eof.error")); + } + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { + pos++; + } else { + space = false; + } + } + // Mark the current buffer position start = pos; end = 0; Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?rev=657954&r1=657953&r2=657954&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java Mon May 19 13:07:20 2008 @@ -454,7 +454,7 @@ if (!fill(true, false)) //request line parsing return false; } - if (buf[pos] == Constants.SP) { + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { space = true; request.method().setBytes(buf, parsingRequestLineStart, pos - parsingRequestLineStart); } @@ -464,20 +464,34 @@ parsingRequestLinePhase = 3; } if ( parsingRequestLinePhase == 3 ) { + // Spec says single SP but also be tolerant of multiple and/or HT + boolean space = true; + while (space) { + // Read new bytes if needed + if (pos >= lastValid) { + if (!fill(true, false)) //request line parsing + return false; + } + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { + pos++; + } else { + space = false; + } + } + // Mark the current buffer position int end = 0; // // Reading the URI // - boolean space = false; while (!space) { // Read new bytes if needed if (pos >= lastValid) { if (!fill(true,false)) //request line parsing return false; } - if (buf[pos] == Constants.SP) { + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { space = true; end = pos; } else if ((buf[pos] == Constants.CR) @@ -504,6 +518,21 @@ parsingRequestLinePhase = 4; } if ( parsingRequestLinePhase == 4 ) { + // Spec says single SP but also be tolerant of multiple and/or HT + boolean space = true; + while (space) { + // Read new bytes if needed + if (pos >= lastValid) { + if (!fill(true, false)) //request line parsing + return false; + } + if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) { + pos++; + } else { + space = false; + } + } + // Mark the current buffer position end = 0; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org