From ba45605afdbb17b4892f27e87080e1f6c37a543f Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 31 Jan 2010 13:22:04 +0000 Subject: [PATCH] Make it clearer how unsupported encodings are handled 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 --- .../apache/catalina/core/ApplicationHttpRequest.java | 8 ++------ java/org/apache/catalina/util/LocalStrings.properties | 2 ++ java/org/apache/catalina/util/RequestUtil.java | 17 +++++++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index 07eb79377..f4af909c8 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -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 keys = parameters.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); diff --git a/java/org/apache/catalina/util/LocalStrings.properties b/java/org/apache/catalina/util/LocalStrings.properties index a3199107a..85f80e44c 100644 --- a/java/org/apache/catalina/util/LocalStrings.properties +++ b/java/org/apache/catalina/util/LocalStrings.properties @@ -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. diff --git a/java/org/apache/catalina/util/RequestUtil.java b/java/org/apache/catalina/util/RequestUtil.java index 2205cff97..9c8c8636d 100644 --- a/java/org/apache/catalina/util/RequestUtil.java +++ b/java/org/apache/catalina/util/RequestUtil.java @@ -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 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 map, byte[] data, String encoding) throws UnsupportedEncodingException { -- 2.11.0