Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-20481

VFS fails to serve file attached to page containing spaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 14.4
    • VFS
    • None
    • Unknown

    Description

      Steps to reproduce

      • Create page Sandbox.VFS.Page with spaces.WebHome.
      • Attach file test.zip to it containing an index.html, eg test.zip
      • Enter Velocity script below in Sandbox.WebHome:
      $services.vfs.url("attach:Sandbox.VFS.Page with spaces.WebHome@test.zip/index.html")
      
      • Display page Sandbox.WebHome.
      • Visit the generated URL, prefixed by http(s)://server-name:port, eg typically:
      http://localhost:8080/xwiki/vfs/attach%3Axwiki%3ASandbox.VFS.Page+with+spaces.WebHome%40test.zip/index.html
      

      Actual result

      The server returns an error 500 with the error below, while when executing the same steps on a page wich does not contain any space, the visited file is served as expected.

      HTTP ERROR 500 javax.servlet.ServletException: Failed to handle Resource Reference [scheme = [attach], reference = [xwiki:Sandbox.VFS.Page with spaces.WebHome@test2.zip], path = [index.html], parameters = []]
      URI:	/xwiki/vfs/attach%3Axwiki%3ASandbox.VFS.Page+with+spaces.WebHome%40test2.zip/index.html
      STATUS:	500
      MESSAGE:	javax.servlet.ServletException: Failed to handle Resource Reference [scheme = [attach], reference = [xwiki:Sandbox.VFS.Page with spaces.WebHome@test2.zip], path = [index.html], parameters = []]
      SERVLET:	default
      CAUSED BY:	javax.servlet.ServletException: Failed to handle Resource Reference [scheme = [attach], reference = [xwiki:Sandbox.VFS.Page with spaces.WebHome@test2.zip], path = [index.html], parameters = []]
      CAUSED BY:	org.xwiki.resource.ResourceReferenceHandlerException: Failed to extract resource [scheme = [attach], reference = [xwiki:Sandbox.VFS.Page with spaces.WebHome@test2.zip], path = [index.html], parameters = []]
      CAUSED BY:	java.lang.IllegalArgumentException: Illegal character in authority at index 9: attach://xwiki:Sandbox.VFS.Page with spaces.WebHome/test2.zip/index.html
      CAUSED BY:	java.net.URISyntaxException: Illegal character in authority at index 9: attach://xwiki:Sandbox.VFS.Page with spaces.WebHome/test2.zip/index.html
      Caused by:
      
      javax.servlet.ServletException: Failed to handle Resource Reference [scheme = [attach], reference = [xwiki:Sandbox.VFS.Page with spaces.WebHome@test2.zip], path = [index.html], parameters = []]
      	at org.xwiki.resource.servlet.ResourceReferenceHandlerServlet.handleResourceReference(ResourceReferenceHandlerServlet.java:161)
      	at org.xwiki.resource.servlet.ResourceReferenceHandlerServlet.service(ResourceReferenceHandlerServlet.java:87)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
      	at org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1419)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
      	at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1624)
      	at org.xwiki.container.servlet.filters.internal.SetHTTPHeaderFilter.doFilter(SetHTTPHeaderFilter.java:63)
      	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
      	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:506)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:596)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1571)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1378)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1544)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1300)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
      	at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:164)
      	at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:135)
      	at org.xwiki.resource.servlet.RoutingFilter.doFilter(RoutingFilter.java:145)
      	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:210)
      	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
      	at org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:164)
      	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
      	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1594)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:506)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1571)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1378)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1544)
      	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1300)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
      	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:192)
      	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:51)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
      	at org.eclipse.jetty.server.Server.handle(Server.java:562)
      	at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:418)
      	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:675)
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:410)
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
      	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
      	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
      	at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
      	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:412)
      	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:381)
      	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:268)
      	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:138)
      	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:407)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: org.xwiki.resource.ResourceReferenceHandlerException: Failed to extract resource [scheme = [attach], reference = [xwiki:Sandbox.VFS.Page with spaces.WebHome@test2.zip], path = [index.html], parameters = []]
      	at org.xwiki.vfs.internal.VfsResourceReferenceHandler.handle(VfsResourceReferenceHandler.java:105)
      	at org.xwiki.resource.internal.DefaultResourceReferenceHandlerChain.handleNext(DefaultResourceReferenceHandlerChain.java:79)
      	at org.xwiki.resource.internal.AbstractResourceReferenceHandlerManager.handle(AbstractResourceReferenceHandlerManager.java:82)
      	at org.xwiki.resource.servlet.ResourceReferenceHandlerServlet.handleResourceReference(ResourceReferenceHandlerServlet.java:159)
      	... 63 more
      Caused by: java.lang.IllegalArgumentException: Illegal character in authority at index 9: attach://xwiki:Sandbox.VFS.Page with spaces.WebHome/test2.zip/index.html
      	at java.base/java.net.URI.create(URI.java:883)
      	at org.xwiki.vfs.internal.attach.AttachURIVfsResourceReferenceSerializer.serialize(AttachURIVfsResourceReferenceSerializer.java:73)
      	at org.xwiki.vfs.internal.attach.AttachURIVfsResourceReferenceSerializer.serialize(AttachURIVfsResourceReferenceSerializer.java:50)
      	at org.xwiki.vfs.internal.URIVfsResourceReferenceSerializer.serialize(URIVfsResourceReferenceSerializer.java:65)
      	at org.xwiki.vfs.internal.URIVfsResourceReferenceSerializer.serialize(URIVfsResourceReferenceSerializer.java:45)
      	at org.xwiki.vfs.internal.VfsResourceReferenceHandler.convertResourceReference(VfsResourceReferenceHandler.java:118)
      	at org.xwiki.vfs.internal.VfsResourceReferenceHandler.handle(VfsResourceReferenceHandler.java:95)
      	... 66 more
      Caused by: java.net.URISyntaxException: Illegal character in authority at index 9: attach://xwiki:Sandbox.VFS.Page with spaces.WebHome/test2.zip/index.html
      	at java.base/java.net.URI$Parser.fail(URI.java:2913)
      	at java.base/java.net.URI$Parser.parseAuthority(URI.java:3247)
      	at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3158)
      	at java.base/java.net.URI$Parser.parse(URI.java:3114)
      	at java.base/java.net.URI.<init>(URI.java:600)
      	at java.base/java.net.URI.create(URI.java:881)
      	... 72 more
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            slauriere slauriere
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: