This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 9277bae15a Fix BZ 66388 - correct regression in removal of URL constructors 9277bae15a is described below commit 9277bae15a52f35e6921a2e2ad6262d7323eb7dd Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Dec 14 18:21:35 2022 +0000 Fix BZ 66388 - correct regression in removal of URL constructors --- java/org/apache/catalina/webresources/AbstractArchiveResource.java | 5 ++++- webapps/docs/changelog.xml | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java/org/apache/catalina/webresources/AbstractArchiveResource.java b/java/org/apache/catalina/webresources/AbstractArchiveResource.java index 534a3db429..8e4daffddc 100644 --- a/java/org/apache/catalina/webresources/AbstractArchiveResource.java +++ b/java/org/apache/catalina/webresources/AbstractArchiveResource.java @@ -22,11 +22,14 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.security.cert.Certificate; import java.util.concurrent.atomic.AtomicBoolean; import java.util.jar.JarEntry; import java.util.jar.Manifest; +import org.apache.catalina.util.URLEncoder; + public abstract class AbstractArchiveResource extends AbstractResource { private final AbstractArchiveResourceSet archiveResourceSet; @@ -139,7 +142,7 @@ public abstract class AbstractArchiveResource extends AbstractResource { @Override public URL getURL() { - String url = baseUrl + resource.getName(); + String url = baseUrl + URLEncoder.DEFAULT.encode(resource.getName(), StandardCharsets.UTF_8); try { return new URI(url).toURL(); } catch (MalformedURLException | URISyntaxException e) { diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 854f21011d..378bbc5ac0 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -114,6 +114,12 @@ reading and writing with <code>ByteBuffer</code>s. The changes also clarified various aspects of the Servlet non-blocking API. (markt) </add> + <fix> + <bug>66388</bug>: Correct a regression in the refactoring that replaced + the use of the <code>URL</code> constructors. The regression broke + lookups for resources that contained one or more characters in their + name that required escaping when used in a URI path. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org