Uploaded image for project: 'JBoss VFS'
  1. JBoss VFS
  2. JBVFS-129

ZipEntryContext cannot handle directory paths with '+' symbols

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.2.0.Alpha1
    • Fix Version/s: 2.2.0.Alpha2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Apache Maven 2.2.0 (r788681; 2009-06-26 09:04:01-0400)
      Java version: 1.6.0_15
      OS name: "mac os x" version: "10.5.8" arch: "x86_64" Family: "mac"

      Description

      When trying to create/use a ZipEntryContext on a zip file whose absolute path contains '+' symbols, the createZipSource() throws an exception looking something like:

      Caused by: java.lang.RuntimeException: Failed to initialize ZipWrapper: /var/folders/JG/JGDYgcyPGF8WRpvalJeL0k+++TI/Tmp/slsb.jar
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getZipSource(ZipEntryContext.java:286)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.ensureEntries(ZipEntryContext.java:637)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.checkIfModified(ZipEntryContext.java:783)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getChild(ZipEntryContext.java:827)
      at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.createChildHandler(ZipEntryHandler.java:195)
      at org.jboss.virtual.plugins.context.AbstractVirtualFileHandler.structuredFindChild(AbstractVirtualFileHandler.java:690)
      at org.jboss.virtual.plugins.context.zip.ZipEntryHandler.getChild(ZipEntryHandler.java:169)
      at org.jboss.virtual.plugins.context.DelegatingHandler.getChild(DelegatingHandler.java:107)
      at org.jboss.virtual.VirtualFile.getChild(VirtualFile.java:492)
      at org.jboss.deployers.vfs.plugins.structure.explicit.DeclaredStructure.determineStructure(DeclaredStructure.java:64)
      ... 40 more
      Caused by: java.io.FileNotFoundException: /var/folders/JG (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(FileInputStream.java:106)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.createZipSource(ZipEntryContext.java:361)
      at org.jboss.virtual.plugins.context.zip.ZipEntryContext.getZipSource(ZipEntryContext.java:282)
      ... 49 more

      Here's my understanding of the source of the problem, based on some debugging & research.
      ZipEntryContext uses URLDecoder.decode() (via VFSUtils.decode()) to convert a file path (which may contain quoted characters, e.g. %20) into a path that the single-String-arg File constructor understands. In the example above, the result is '/var/folders/JG/JGDYgcyPGF8WRpvalJeL0k TI/Tmp/slsb.jar', which is obviously incorrect.

      I think using URLDecoder.decode() is a faulty strategy. I'll attach my suggested fix.

      (This problem would especially cause problems for OS X users, since the OS X temp directory (always? often?) contains '+++' in its path. This is the case in the stacktrace above. A workaround for this particular problem is to use -Djava.io.tmpdir=/some/path/without/pluses)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                alesj Ales Justin
                Reporter:
                matt.drees Matt Drees
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: