You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/03/16 17:48:07 UTC
[tomcat] 01/04: Make all calls to URLDecode use an explicit
character set
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 8fcd0518d443ba67f76352adc2b28a62b4e8c460
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 16 15:57:13 2020 +0000
Make all calls to URLDecode use an explicit character set
---
java/org/apache/catalina/loader/WebappLoader.java | 5 +++--
test/org/apache/tomcat/util/buf/TestUDecoder.java | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index 8ddf716..8d93226 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.charset.StandardCharsets;
import javax.management.ObjectName;
import javax.servlet.ServletContext;
@@ -612,9 +613,9 @@ public class WebappLoader extends LifecycleMBeanBase
for (int i = 0; i < repositories.length; i++) {
String repository = repositories[i].toString();
if (repository.startsWith("file://"))
- repository = UDecoder.URLDecode(repository.substring(7));
+ repository = UDecoder.URLDecode(repository.substring(7), StandardCharsets.ISO_8859_1);
else if (repository.startsWith("file:"))
- repository = UDecoder.URLDecode(repository.substring(5));
+ repository = UDecoder.URLDecode(repository.substring(5), StandardCharsets.ISO_8859_1);
else
continue;
if (repository == null)
diff --git a/test/org/apache/tomcat/util/buf/TestUDecoder.java b/test/org/apache/tomcat/util/buf/TestUDecoder.java
index d3264c2..ca7dd23 100644
--- a/test/org/apache/tomcat/util/buf/TestUDecoder.java
+++ b/test/org/apache/tomcat/util/buf/TestUDecoder.java
@@ -28,7 +28,7 @@ public class TestUDecoder {
// %n rather than %nn should throw an IAE according to the Javadoc
Exception exception = null;
try {
- UDecoder.URLDecode("%5xxxxx");
+ UDecoder.URLDecode("%5xxxxx", StandardCharsets.UTF_8);
} catch (Exception e) {
exception = e;
}
@@ -37,7 +37,7 @@ public class TestUDecoder {
// Edge case trying to trigger ArrayIndexOutOfBoundsException
exception = null;
try {
- UDecoder.URLDecode("%5");
+ UDecoder.URLDecode("%5", StandardCharsets.UTF_8);
} catch (Exception e) {
exception = e;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org