Make it clearer how unsupported encodings are handled
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 31 Jan 2010 13:22:04 +0000 (13:22 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 31 Jan 2010 13:22:04 +0000 (13:22 +0000)
No functional change for supported encodings
Log attempted use of unsupported encodings, removing some empty catch blocks in the process

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@905035 13f79535-47bb-0310-9956-ffa450edef68

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

index 07eb793..f4af909 100644 (file)
@@ -882,12 +882,8 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         String encoding = getCharacterEncoding();
         if (encoding == null)
             encoding = "ISO-8859-1";
-        try {
-            RequestUtil.parseParameters
-                (queryParameters, queryParamString, encoding);
-        } catch (Exception e) {
-            // Ignore
-        }
+        RequestUtil.parseParameters(queryParameters, queryParamString,
+                encoding);
         Iterator<String> keys = parameters.keySet().iterator();
         while (keys.hasNext()) {
             String key = keys.next();
index a319910..85f80e4 100644 (file)
@@ -22,5 +22,7 @@ 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.parseParameters.uee=Unable to parse the parameters since the encoding [{0}] is not supported.
+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 2205cff..9c8c863 100644 (file)
@@ -184,11 +184,12 @@ public final class RequestUtil {
      *
      * @param map Map that accumulates the resulting parameters
      * @param data Input string containing request parameters
-     *
-     * @exception IllegalArgumentException if the data is malformed
+     * @param encoding The encoding to use; if null, the default encoding is
+     * used. If an unsupported encoding is specified the parameters will not be
+     * parsed and the map will not be modified
      */
     public static void parseParameters(Map<String,String[]> map, String data,
-            String encoding) throws UnsupportedEncodingException {
+            String encoding) {
 
         if ((data != null) && (data.length() > 0)) {
 
@@ -202,10 +203,12 @@ public final class RequestUtil {
                 } else {
                     bytes = data.getBytes(encoding);
                 }
+                parseParameters(map, bytes, encoding);
             } catch (UnsupportedEncodingException uee) {
+                log.debug(sm.getString("requestUtil.parseParameters.uee",
+                        encoding), uee);
             }
 
-            parseParameters(map, bytes, encoding);
         }
 
     }
@@ -391,9 +394,11 @@ public final class RequestUtil {
      *
      * @param map Map that accumulates the resulting parameters
      * @param data Input string containing request parameters
-     * @param encoding Encoding to use for converting hex
+     * @param encoding The encoding to use; if null, the default encoding is
+     * used
      *
-     * @exception UnsupportedEncodingException if the data is malformed
+     * @exception UnsupportedEncodingException if the requested encoding is not
+     * supported.
      */
     public static void parseParameters(Map<String,String[]> map, byte[] data,
             String encoding) throws UnsupportedEncodingException {