Align implementation with comments. Unit test now passes.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 31 Jan 2010 17:07:26 +0000 (17:07 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 31 Jan 2010 17:07:26 +0000 (17:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@905073 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/util/LocalStrings.properties
java/org/apache/catalina/util/RequestUtil.java

index 85f80e4..d101e52 100644 (file)
@@ -22,7 +22,9 @@ extensionValidator.web-application-manifest=Web Application Manifest
 extensionValidator.extension-not-found-error=ExtensionValidator[{0}][{1}]: Required extension "{2}" not found.
 extensionValidator.extension-validation-error=ExtensionValidator[{0}]: Failure to find {1} required extension(s).
 extensionValidator.failload=Failure loading extension {0}
+requestUtil.convertHexDigit.notHex=[{0}] is not a hexadecimal digit
 requestUtil.parseParameters.uee=Unable to parse the parameters since the encoding [{0}] is not supported.
+requestUtil.urlDecode.missingDigit=The % character must be followed by two hexademical digits
 requestUtil.urlDecode.uee=Unable to URL decode the specified input since the encoding [{0}] is not supported.
 SecurityUtil.doAsPrivilege=An exception occurs when running the PrivilegedExceptionAction block.
 
index 150f6ec..b1357e8 100644 (file)
@@ -326,6 +326,10 @@ public final class RequestUtil {
             if (b == '+' && isQuery) {
                 b = (byte)' ';
             } else if (b == '%') {
+                if (ix + 2 >= len) {
+                    throw new IllegalArgumentException(
+                            sm.getString("requestUtil.urlDecode.missingDigit"));
+                }
                 b = (byte) ((convertHexDigit(bytes[ix++]) << 4)
                             + convertHexDigit(bytes[ix++]));
             }
@@ -353,7 +357,9 @@ public final class RequestUtil {
         if ((b >= '0') && (b <= '9')) return (byte)(b - '0');
         if ((b >= 'a') && (b <= 'f')) return (byte)(b - 'a' + 10);
         if ((b >= 'A') && (b <= 'F')) return (byte)(b - 'A' + 10);
-        return 0;
+        throw new IllegalArgumentException(
+                sm.getString("requestUtil.convertHexDigit.notHex",
+                        Character.valueOf((char)b)));
     }