Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 13517 invoked from network); 9 Feb 2011 23:41:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Feb 2011 23:41:57 -0000 Received: (qmail 51164 invoked by uid 500); 9 Feb 2011 23:41:56 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 51026 invoked by uid 500); 9 Feb 2011 23:41:55 -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 51017 invoked by uid 99); 9 Feb 2011 23:41:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Feb 2011 23:41:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Wed, 09 Feb 2011 23:41:53 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8F5A623889EA; Wed, 9 Feb 2011 23:41:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1069170 - in /tomcat/trunk: java/org/apache/catalina/util/RequestUtil.java test/org/apache/catalina/util/TestRequestUtil.java webapps/docs/changelog.xml Date: Wed, 09 Feb 2011 23:41:32 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110209234132.8F5A623889EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Wed Feb 9 23:41:32 2011 New Revision: 1069170 URL: http://svn.apache.org/viewvc?rev=1069170&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50721 Correctly handle URL decoding where the URL ends in %nn. Patch (for fix) provided by Christof Marti. Additional test cases added. Modified: tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java?rev=1069170&r1=1069169&r2=1069170&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java (original) +++ tomcat/trunk/java/org/apache/catalina/util/RequestUtil.java Wed Feb 9 23:41:32 2011 @@ -326,7 +326,7 @@ public final class RequestUtil { if (b == '+' && isQuery) { b = (byte)' '; } else if (b == '%') { - if (ix + 2 >= len) { + if (ix + 2 > len) { throw new IllegalArgumentException( sm.getString("requestUtil.urlDecode.missingDigit")); } Modified: tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java?rev=1069170&r1=1069169&r2=1069170&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java (original) +++ tomcat/trunk/test/org/apache/catalina/util/TestRequestUtil.java Wed Feb 9 23:41:32 2011 @@ -28,7 +28,7 @@ public class TestRequestUtil extends Tes assertEquals("/",RequestUtil.normalize("//")); } - public void testURLDecodeString() { + public void testURLDecodeStringInvalid() { // %n rather than %nn should throw an IAE according to the Javadoc Exception exception = null; try { @@ -47,4 +47,40 @@ public class TestRequestUtil extends Tes } assertTrue(exception instanceof IllegalArgumentException); } + + public void testURLDecodeStringValidIso88591Start() { + + String result = RequestUtil.URLDecode("%41xxxx", "ISO-8859-1"); + assertEquals("Axxxx", result); + } + + public void testURLDecodeStringValidIso88591Middle() { + + String result = RequestUtil.URLDecode("xx%41xx", "ISO-8859-1"); + assertEquals("xxAxx", result); + } + + public void testURLDecodeStringValidIso88591End() { + + String result = RequestUtil.URLDecode("xxxx%41", "ISO-8859-1"); + assertEquals("xxxxA", result); + } + + public void testURLDecodeStringValidUtf8Start() { + String result = RequestUtil.URLDecode("%c3%aaxxxx", "UTF-8"); + assertEquals("\u00eaxxxx", result); + } + + public void testURLDecodeStringValidUtf8Middle() { + + String result = RequestUtil.URLDecode("xx%c3%aaxx", "UTF-8"); + assertEquals("xx\u00eaxx", result); + } + + public void testURLDecodeStringValidUtf8End() { + + String result = RequestUtil.URLDecode("xxxx%c3%aa", "UTF-8"); + assertEquals("xxxx\u00ea", result); + } + } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1069170&r1=1069169&r2=1069170&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Wed Feb 9 23:41:32 2011 @@ -64,8 +64,12 @@ the expected state transitions. (markt) + 50721: Correctly handle URL decoding where the URL ends in + %nn. Patch provided by Christof Marti. (markt) + + 50748: Allow the content length header to be set up to the - point the response is committed when a writer is beng used. (markt) + point the response is committed when a writer is being used. (markt) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org