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 19:06:08 UTC
[tomcat] branch 7.0.x updated (a72847f -> 60d3ab3)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.
from a72847f Be explicit that UTF-8 is used for encoded dispatcher paths
new 3bb4e13 Make all calls to URLDecode use an explicit character set
new 7717f86 Deprecated unused method
new 7255cd4 Call byte decode method directly.
new 60d3ab3 Deprecate unused methods / methods that will be removed later
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 | 5 ++--
.../apache/catalina/core/ApplicationContext.java | 3 ++-
java/org/apache/catalina/loader/WebappLoader.java | 8 +++---
java/org/apache/tomcat/util/buf/UDecoder.java | 30 +++++++++++++++++++---
test/org/apache/catalina/util/TestRequestUtil.java | 4 +--
5 files changed, 38 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 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 3bb4e130fc1a44c24b6efcd23f6c4e23733f4eda
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/core/ApplicationContext.java | 3 ++-
java/org/apache/catalina/loader/WebappLoader.java | 8 ++++----
test/org/apache/catalina/util/TestRequestUtil.java | 4 ++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java
index 881d513..e76c54c 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -74,6 +74,7 @@ import org.apache.catalina.util.URLEncoder;
import org.apache.naming.resources.DirContextURLStreamHandler;
import org.apache.naming.resources.Resource;
import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.CharChunk;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.buf.UDecoder;
@@ -446,7 +447,7 @@ public class ApplicationContext implements ServletContext {
if (getContext().getDispatchersUseEncodedPaths()) {
// Decode
- String decodedUri = UDecoder.URLDecode(normalizedUri, StandardCharsets.UTF_8);
+ String decodedUri = UDecoder.URLDecode(normalizedUri, B2CConverter.UTF_8);
// Security check to catch attempts to encode /../ sequences
normalizedUri = RequestUtil.normalize(decodedUri);
diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index d2d2751..b39e9c1 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -55,6 +55,7 @@ import org.apache.naming.resources.DirContextURLStreamHandler;
import org.apache.naming.resources.DirContextURLStreamHandlerFactory;
import org.apache.naming.resources.Resource;
import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.UDecoder;
import org.apache.tomcat.util.compat.JreCompat;
import org.apache.tomcat.util.modeler.Registry;
@@ -1107,12 +1108,11 @@ 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), B2CConverter.ISO_8859_1);
else if (repository.startsWith("file:"))
- repository = UDecoder.URLDecode(repository.substring(5));
+ repository = UDecoder.URLDecode(repository.substring(5), B2CConverter.ISO_8859_1);
else if (repository.startsWith("jndi:"))
- repository =
- servletContext.getRealPath(repository.substring(5));
+ repository = servletContext.getRealPath(repository.substring(5));
else
continue;
if (repository == null)
diff --git a/test/org/apache/catalina/util/TestRequestUtil.java b/test/org/apache/catalina/util/TestRequestUtil.java
index a566737..1974587 100644
--- a/test/org/apache/catalina/util/TestRequestUtil.java
+++ b/test/org/apache/catalina/util/TestRequestUtil.java
@@ -26,7 +26,7 @@ public class TestRequestUtil {
// %n rather than %nn should throw an IAE according to the Javadoc
Exception exception = null;
try {
- RequestUtil.URLDecode("%5xxxxx");
+ RequestUtil.URLDecode("%5xxxxx", "UTF-8");
} catch (Exception e) {
exception = e;
}
@@ -35,7 +35,7 @@ public class TestRequestUtil {
// Edge case trying to trigger ArrayIndexOutOfBoundsException
exception = null;
try {
- RequestUtil.URLDecode("%5");
+ RequestUtil.URLDecode("%5", "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] 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 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 7717f860271c3a44044eeb6a859eef4a5e85aaf5
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 0689d1e..6d123ea 100644
--- a/java/org/apache/tomcat/util/buf/UDecoder.java
+++ b/java/org/apache/tomcat/util/buf/UDecoder.java
@@ -350,7 +350,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, B2CConverter.UTF_8);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 03/04: 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 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 7255cd488d9fadce8b473daa803dee7eb31a64da
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 16 16:18:53 2020 +0000
Call byte decode method directly.
---
java/org/apache/catalina/connector/CoyoteAdapter.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java b/java/org/apache/catalina/connector/CoyoteAdapter.java
index fc0fdd0..783fc24 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -721,13 +721,14 @@ public class CoyoteAdapter implements Adapter {
// Parse the path parameters. This will:
// - strip out the path parameters
- // - convert the decodedURI to bytes
+ // - convert the decodedURI to bytes (if it isn't already)
parsePathParameters(req, request);
// URI decoding
// %xx decoding of the URL
try {
- req.getURLDecoder().convert(decodedURI, false);
+ // Will always by in bytes at this point
+ req.getURLDecoder().convert(decodedURI.getByteChunk(), false);
} catch (IOException ioe) {
res.setStatus(400);
res.setMessage("Invalid URI: " + ioe.getMessage());
---------------------------------------------------------------------
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 / methods that will be
removed later
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 60d3ab3636f0efe94b6e01a48dd6949585cd63d2
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Mar 16 16:23:15 2020 +0000
Deprecate unused methods / methods that will be removed later
---
java/org/apache/tomcat/util/buf/UDecoder.java | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/tomcat/util/buf/UDecoder.java b/java/org/apache/tomcat/util/buf/UDecoder.java
index 6d123ea..44696f2 100644
--- a/java/org/apache/tomcat/util/buf/UDecoder.java
+++ b/java/org/apache/tomcat/util/buf/UDecoder.java
@@ -68,7 +68,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
* @throws IOException Invalid %xx URL encoding
* @deprecated Unused. Will be removed in Tomcat 8.0.x onwards.
@@ -138,10 +140,12 @@ 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
* @throws IOException Invalid %xx URL encoding
* @deprecated Unused. Will be removed in Tomcat 8.0.x onwards.
@@ -158,7 +162,10 @@ public final class UDecoder {
* @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
{
@@ -226,10 +233,16 @@ public final class UDecoder {
/**
* 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
{
@@ -272,11 +285,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 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