* Align %2f handling between implementations of UDecoder.convert()
http://svn.apache.org/viewvc?rev=1203091&view=rev
+1: kkolinko, markt, funkman, jim
-1:
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc5.5.x/trunk@1221288 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java b/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
index 81e946d..eb852cb 100644
--- a/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
+++ b/connectors/util/java/org/apache/tomcat/util/buf/UDecoder.java
@@ -94,7 +94,7 @@
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 @@
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 @@
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 @@
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 @@
// 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;
}
}