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:06 UTC
[tomcat] branch 8.5.x updated (cccb520 -> 9f2174f)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.
from cccb520 Be explicit that UTF-8 is used for encoded dispatcher paths
new 8fcd051 Make all calls to URLDecode use an explicit character set
new 7ee3a5c Deprecated unused method
new 26ff6f7 Simplify comment. Call byte decode method directly.
new 9f2174f Deprecate unused methods
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/catalina/connector/CoyoteAdapter.java | 6 ++--
java/org/apache/catalina/loader/WebappLoader.java | 5 ++--
java/org/apache/tomcat/util/buf/UDecoder.java | 32 +++++++++++++++++++---
test/org/apache/tomcat/util/buf/TestUDecoder.java | 4 +--
4 files changed, 35 insertions(+), 12 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 01/04: Make all calls to URLDecode use an explicit
character set
Posted by ma...@apache.org.
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
[tomcat] 04/04: Deprecate unused methods
Posted by ma...@apache.org.
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 9f2174f7061f79b5ea99a2bd1d68d73fb357a752
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 16 16:23:15 2020 +0000
Deprecate unused methods
---
java/org/apache/tomcat/util/buf/UDecoder.java | 29 +++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/tomcat/util/buf/UDecoder.java b/java/org/apache/tomcat/util/buf/UDecoder.java
index 40ae275..c7ff567 100644
--- a/java/org/apache/tomcat/util/buf/UDecoder.java
+++ b/java/org/apache/tomcat/util/buf/UDecoder.java
@@ -74,7 +74,9 @@ public final class UDecoder {
}
/**
- * URLDecode, will modify the source.
+ * URLDecode, will modify the source. Assumes source bytes are encoded using
+ * a superset of US-ASCII as per RFC 7230.
+ *
* @param mb The URL encoded bytes
* @param query <code>true</code> if this is a query string
* @throws IOException Invalid %xx URL encoding
@@ -132,14 +134,19 @@ public final class UDecoder {
}
// -------------------- Additional methods --------------------
- // XXX What do we do about charset ????
/**
* In-buffer processing - the buffer will be modified.
+ * <p>
+ * <b>WARNING:</b> This method assumes US-ASCII encoding.
+ *
* @param mb The URL encoded chars
* @param query <code>true</code> if this is a query string
* @throws IOException Invalid %xx URL encoding
+ *
+ * @deprecated Unused. Will be removed in Tomcat 10
*/
+ @Deprecated
public void convert( CharChunk mb, boolean query )
throws IOException
{
@@ -193,11 +200,17 @@ public final class UDecoder {
}
/**
- * URLDecode, will modify the source
+ * URLDecode, will modify the source.
+ * <p>
+ * <b>WARNING:</b> This method assumes US-ASCII encoding.
+ *
* @param mb The URL encoded String, bytes or chars
* @param query <code>true</code> if this is a query string
* @throws IOException Invalid %xx URL encoding
+ *
+ * @deprecated Unused. Will be removed in Tomcat 10
*/
+ @Deprecated
public void convert(MessageBytes mb, boolean query)
throws IOException
{
@@ -226,11 +239,19 @@ public final class UDecoder {
}
/**
- * %xx decoding of a string. FIXME: this is inefficient.
+ * %xx decoding of a string.
+ * <p>
+ * <b>WARNING:</b> This method assumes US-ASCII encoding.
+ * <p>
+ * FIXME: this is inefficient.
+ *
* @param str The URL encoded string
* @param query <code>true</code> if this is a query string
* @return the decoded string
+ *
+ * @deprecated Unused. Will be removed in Tomcat 10
*/
+ @Deprecated
public final String convert(String str, boolean query)
{
if (str == null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 03/04: Simplify comment. Call byte decode method directly.
Posted by ma...@apache.org.
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 26ff6f723213730b6802df30c76ba37d24141fce
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 16 16:18:53 2020 +0000
Simplify comment. Call byte decode method directly.
---
java/org/apache/catalina/connector/CoyoteAdapter.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java b/java/org/apache/catalina/connector/CoyoteAdapter.java
index 0d81f6d..e7cc9ed 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -624,15 +624,13 @@ public class CoyoteAdapter implements Adapter {
// Copy the raw URI to the decodedURI
decodedURI.duplicate(undecodedURI);
- // Parse the path parameters. This will:
- // - strip out the path parameters
- // - convert the decodedURI to bytes
+ // Parse (and strip out) the path parameters
parsePathParameters(req, request);
// URI decoding
// %xx decoding of the URL
try {
- req.getURLDecoder().convert(decodedURI, false);
+ req.getURLDecoder().convert(decodedURI.getByteChunk(), false);
} catch (IOException ioe) {
response.sendError(400, "Invalid URI: " + ioe.getMessage());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 02/04: Deprecated unused method
Posted by ma...@apache.org.
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 7ee3a5c90ed75c4147690aaf10d356f13d41c834
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 16 16:03:12 2020 +0000
Deprecated unused method
---
java/org/apache/tomcat/util/buf/UDecoder.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/java/org/apache/tomcat/util/buf/UDecoder.java b/java/org/apache/tomcat/util/buf/UDecoder.java
index fa0523a..40ae275 100644
--- a/java/org/apache/tomcat/util/buf/UDecoder.java
+++ b/java/org/apache/tomcat/util/buf/UDecoder.java
@@ -304,7 +304,10 @@ public final class UDecoder {
* @return the decoded string
* @exception IllegalArgumentException if a '%' character is not followed
* by a valid 2-digit hexadecimal number
+ *
+ * @deprecated Unused. This will be removed in Tomcat 10 onwards
*/
+ @Deprecated
public static String URLDecode(String str) {
return URLDecode(str, StandardCharsets.ISO_8859_1);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org