jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Jetty 12 : Rework `PathResource.checkAliasPath` to handle `jar:file:` paths more elegantly

Open joakime opened this issue 3 years ago • 1 comments

Reworked the PathResource.checkAliasPath ...

If the URI is a jar:file: based, the URI only check is skipped and the path segment checks still apply. Also, the symlink check is skipped (as it's not possible to have symlinks in zipfs)

joakime avatar Aug 09 '22 15:08 joakime

I need more test cases!

What is a combination of ..

  1. A zipfs PathResource
  2. A request path used in resolve(String) that resolves to a resource that exists, but can be viewed as an alias.

joakime avatar Aug 09 '22 15:08 joakime

@joakime Can you look at the disabled test org.eclipse.jetty.ee10.servlet.DefaultServletTest#testListingFilenamesOnlyUrlResource in relation to the changes in this PR.

Is using jar:file URIs and in 12.0.x was failing because it was being classified as an alias because of trailing slash. But now on this PR the test it is throwing UnsupportedOperationException.

java.lang.UnsupportedOperationException
	at jdk.zipfs/jdk.nio.zipfs.ZipPath.toFile(ZipPath.java:669)
	at org.eclipse.jetty.server/org.eclipse.jetty.server.ResourceListing.getAsHTML(ResourceListing.java:207)
	at org.eclipse.jetty.server/org.eclipse.jetty.server.ResourceService.sendDirectory(ResourceService.java:530)
	at org.eclipse.jetty.server/org.eclipse.jetty.server.ResourceService.sendWelcome(ResourceService.java:438)
	at org.eclipse.jetty.server/org.eclipse.jetty.server.ResourceService.doGet(ResourceService.java:166)
	at org.eclipse.jetty.ee10.servlet/org.eclipse.jetty.ee10.servlet.DefaultServlet.doGet(DefaultServlet.java:388)
	at [email protected]/jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
	at [email protected]/jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
	at org.eclipse.jetty.ee10.servlet/org.eclipse.jetty.ee10.servlet.ServletHolder.handle(ServletHolder.java:742)

lachlan-roberts avatar Aug 31 '22 23:08 lachlan-roberts

This is related to https://github.com/eclipse/jetty.project/issues/8462 as well.

lorban avatar Sep 02 '22 07:09 lorban