Details
Description
I'm emphasized assert statement which causes the issue
@Test public void packageResourceGuard() throws Exception { PackageResourceGuard guard = new PackageResourceGuard(); assertTrue(guard.acceptExtension("txt")); assertFalse(guard.acceptExtension("java")); assertTrue(guard.acceptAbsolutePath("foo/Bar.txt")); assertFalse(guard.acceptAbsolutePath("foo/Bar.java")); assertTrue(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, "Bar.txt"))); assertTrue(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, "Bar.txt."))); assertTrue(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, ".Bar.txt"))); assertTrue(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, ".Bar.txt."))); assertTrue(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, ".Bar"))); >>>> assertTrue(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, ".java"))); assertFalse(guard.accept(PackageResourceTest.class, Packages.absolutePath(PackageResourceTest.class, "Bar.java"))); }
There is another issue in PackageResourceGuardTest
@Test public void acceptAbsolutePath() { PackageResourceGuard guard = new PackageResourceGuard(); guard.setAllowAccessToRootResources(false); assertTrue(guard.acceptAbsolutePath("/test/test.js")); assertFalse(guard.acceptAbsolutePath("/test.js")); >>> File.pathSeparator must be replaced with File.separator >>> if ("\\".equals(File.pathSeparator)) { assertTrue(guard.acceptAbsolutePath("c:\\test\\org\\apache\\test.js")); assertTrue(guard.acceptAbsolutePath("\\test\\org\\apache\\test.js")); assertFalse(guard.acceptAbsolutePath("c:\\test.js")); assertFalse(guard.acceptAbsolutePath("\\test.js")); // java also generates file paths with '/' on windows assertTrue(guard.acceptAbsolutePath("c:/test/org/apache/test.js")); assertTrue(guard.acceptAbsolutePath("/test/org/apache/test.js")); assertFalse(guard.acceptAbsolutePath("c:/test.js")); assertFalse(guard.acceptAbsolutePath("/test.js")); } }
Attachments
Issue Links
- is broken by
-
WICKET-5098 PackageResourceBlockedException under Windows for *.js files in web app's own packages, not in jars
- Resolved