From 4ab08c0e80803e31b9b538d648cca80e52d3507b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 10 May 2017 14:23:52 +0200 Subject: [PATCH] Issue #1539 decode path in jar:file --- .../jetty/util/resource/JarFileResource.java | 3 ++- .../jetty/util/resource/JarResourceTest.java | 8 ++++++++ .../src/test/resources/TestData/test.zip | Bin 1406 -> 1788 bytes 3 files changed, 10 insertions(+), 1 deletion(-) 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 93d14cc0a3e700d50855143455798394a5cd68fc..e620b0ea7522e114e82336e6ee8717285e47c297 100644 GIT binary patch literal 1788 zcmWIWW@Zs#;Nak3aLixj#ef7j8CV#6T|*poJ^kGD|D9rBU}gyLX6FE@V1gD$MzpZPg>xcE4Ex%)eM9x;K9XAsktD|jyy2C5ZA zF%8{;>_FMP(%hufqGDqcBQrx&eK>sX7^CHNE;?ks) z%p!e+qi3Nh;zuYVJ2)WLuS7E$@gCN0WgO++Yfd-YN7MCcX#uvIWF=S;Zsm=S$Y5kKPx-W(DPEQ~=MQpxlkF6*-52ax((h0-12FNO>FC1W-ap&QRcD18&4& zAPW}j$htt84LRe0yo3N^jA&U8Su4mw03krVNZAD8e~>oh^bX1> c2vCiz4JF$Ic(byB)bRqL1W?sEAZB0y0OrMB&j0`b delta 404 zcmeyv`;Ut+z?+#xgnrs(o0M8q9N^8!#Kph`bO_KoF?k>j1rb0s#idCpnML{_H4sZC8?Y)c)=my& z6=Q=6Sh6WFU1yve%_a#nJC{{~Nr7pyBap${37Gw0dNWv~EZnWEY#?Efdy|+L7}%IWJOJzuQlbC=