Author: jim
Date: Tue Dec 20 14:45:12 2011
New Revision: 1221288

URL: http://svn.apache.org/viewvc?rev=1221288&view=rev
Log:
* Align %2f handling between implementations of UDecoder.convert()
  http://svn.apache.org/viewvc?rev=1203091&view=rev
  +1: kkolinko, markt, funkman, jim
  -1:


Modified:
    
tomcat/tc5.5.x/trunk/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java

Modified: 
tomcat/tc5.5.x/trunk/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc5.5.x/trunk/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java?rev=1221288&r1=1221287&r2=1221288&view=diff
==============================================================================
--- 
tomcat/tc5.5.x/trunk/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
 (original)
+++ 
tomcat/tc5.5.x/trunk/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
 Tue Dec 20 14:45:12 2011
@@ -94,7 +94,7 @@ public final class UDecoder {
             idx=idx2;
         }
 
-        boolean noSlash = !(ALLOW_ENCODED_SLASH || query);
+        final boolean noSlash = !(ALLOW_ENCODED_SLASH || query);
 
         for( int j=idx; j<end; j++, idx++ ) {
             if( buff[ j ] == '+' && query) {
@@ -161,7 +161,7 @@ public final class UDecoder {
             idx=idx2;
         }
     
-        boolean noSlash = !(ALLOW_ENCODED_SLASH || query);
+        final boolean noSlash = !(ALLOW_ENCODED_SLASH || query);
         for( int j=idx; j<cend; j++, idx++ ) {
             if( buff[ j ] == '+' && query ) {
                 buff[idx]=( ' ' );
@@ -208,7 +208,11 @@ public final class UDecoder {
         case MessageBytes.T_STR:
             String strValue=mb.toString();
             if( strValue==null ) return;
-            mb.setString( convert( strValue, query ));
+            try {
+                mb.setString( convert( strValue, query ));
+            } catch (RuntimeException ex) {
+                throw new DecodeException(ex.getMessage());
+            }
             break;
         case MessageBytes.T_CHARS:
             CharChunk charC=mb.getCharChunk();
@@ -234,7 +238,9 @@ public final class UDecoder {
         
         if( (!query || str.indexOf( '+' ) < 0) && str.indexOf( '%' ) < 0 )
             return str;
-        
+
+        final boolean noSlash = !(ALLOW_ENCODED_SLASH || query);
+
         StringBuffer dec = new StringBuffer();    // decoded string output
         int strPos = 0;
         int strLen = str.length();
@@ -272,8 +278,12 @@ public final class UDecoder {
                 // We throw the original exception - the super will deal with
                 // it
                 //                try {
-                dec.append((char)Integer.
-                           parseInt(str.substring(strPos + 1, strPos + 3),16));
+                char res = (char) Integer.parseInt(
+                        str.substring(strPos + 1, strPos + 3), 16);
+                if (noSlash && (res == '/')) {
+                    throw new IllegalArgumentException("noSlash");
+                }
+                dec.append(res);
                 strPos += 3;
             }
         }



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

Reply via email to