diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java index 62f3f4bbcd9..dc95ab451fc 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -123,7 +124,7 @@ class JarFileResource extends JarResource int sep = _urlString.lastIndexOf("!/"); _jarUrl=_urlString.substring(0,sep+2); - _path=_urlString.substring(sep+2); + _path=URIUtil.decodePath(_urlString.substring(sep+2)); if (_path.length()==0) _path=null; _jarFile=_jarConnection.getJarFile(); diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/JarResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/JarResourceTest.java index 95159783dc4..343f63774e0 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/JarResourceTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/JarResourceTest.java @@ -201,5 +201,13 @@ public class JarResourceTest assertFalse(dest.exists()); } + @Test + public void testEncodedFileName() + throws Exception + { + String s = "jar:"+testResURI+"TestData/test.zip!/file%20name.txt"; + Resource r = Resource.newResource(s); + assertTrue(r.exists()); + } } diff --git a/jetty-util/src/test/resources/TestData/test.zip b/jetty-util/src/test/resources/TestData/test.zip index 93d14cc0a3e..e620b0ea752 100644 Binary files a/jetty-util/src/test/resources/TestData/test.zip and b/jetty-util/src/test/resources/TestData/test.zip differ