473243 Delay resource close for async default content

This commit is contained in:
Greg Wilkins 2015-07-22 12:34:56 +10:00
parent dee941c365
commit e4bf5d888c
2 changed files with 18 additions and 1 deletions

View File

@ -301,7 +301,7 @@ public class URLResource extends Resource
path = URIUtil.canonicalPath(path); path = URIUtil.canonicalPath(path);
return newResource(URIUtil.addPaths(_url.toExternalForm(),path), _useCaches); return newResource(URIUtil.addPaths(_url.toExternalForm(),URIUtil.encodePath(path)), _useCaches);
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */

View File

@ -38,6 +38,8 @@ import java.util.zip.ZipFile;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -344,6 +346,21 @@ public class ResourceTest
} }
} }
/* ------------------------------------------------------------ */
@Test
public void testEncodeAddPath ()
throws Exception
{
Resource r;
r = Resource.newResource(__userURL+"TestData/").addPath("foo%/b r");
Assert.assertThat(r.getURI().toString(),Matchers.endsWith("/foo%25/b%20r"));
r = Resource.newResource("jar:"+__userURL+"TestData/test.zip!/subdir/").addPath("foo%/b r");
Assert.assertThat(r.getURI().toString(),Matchers.endsWith("/foo%25/b%20r"));
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@Test @Test
public void testJarFileCopyToDirectoryTraversal () throws Exception public void testJarFileCopyToDirectoryTraversal () throws Exception