JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6172

Requiring a file from a JAR that has a path inside the JAR that coincides with a path on the file system that includes a symlink fails

    Details

    • Number of attachments :
      2

      Description

      It all boils down to org.jruby.runtime.load.LoadService#expandRelativeJarPath using File#getCanonicalPath to expand the JAR entry path. A quick fix is to change expandRelativeJarPath like this:

          private String expandRelativeJarPath(String path) {
              return path.replaceAll("/[^/]+/\\.\\.|[^/]+/\\.\\./|\\./","").replace("^\\\\","/");
          }
      

      This passes all existing tests and fixes the problem. I can add a test and submit a patch if desired.

        Activity

        Hide
        Uwe Kubosch added a comment -

        Attached patch with fix.

        Show
        Uwe Kubosch added a comment - Attached patch with fix.
        Hide
        Hiro Asari added a comment -

        Can we have a test case, so that we can test it? Thanks.

        Show
        Hiro Asari added a comment - Can we have a test case, so that we can test it? Thanks.
        Hide
        Uwe Kubosch added a comment -

        I am having a bit of trouble creating a test case that will fail on any system. The problem only occurs if you try to load a file with a path in a JAR that also exists at the root of your file system and includes a symlink.

        I will try a bit further. Any tip on how to test it is appreciated.

        Show
        Uwe Kubosch added a comment - I am having a bit of trouble creating a test case that will fail on any system. The problem only occurs if you try to load a file with a path in a JAR that also exists at the root of your file system and includes a symlink. I will try a bit further. Any tip on how to test it is appreciated.
        Hide
        Uwe Kubosch added a comment -

        I do have a test that fails with existing code, but only when I run it alone. The contamination from the other tests seems to be a required JAR file.

        Is there a way to "unrequire" a JAR file?

        Show
        Uwe Kubosch added a comment - I do have a test that fails with existing code, but only when I run it alone. The contamination from the other tests seems to be a required JAR file. Is there a way to "unrequire" a JAR file?
        Hide
        Uwe Kubosch added a comment -

        Attached patch with test that fails on old code when run alone and runs OK with the proposed code change.

        Show
        Uwe Kubosch added a comment - Attached patch with test that fails on old code when run alone and runs OK with the proposed code change.
        Hide
        Uwe Kubosch added a comment -

        Updated the attached test to spawn a fresh jruby process to make it fail independently of other tests. It works now. Could you look at it?

        Show
        Uwe Kubosch added a comment - Updated the attached test to spawn a fresh jruby process to make it fail independently of other tests. It works now. Could you look at it?
        Hide
        Hiro Asari added a comment -

        Uwe,

        Thanks for the test and the patch. I've pushed them to the master branch (d956b62 and 080e23d).

        Show
        Hiro Asari added a comment - Uwe, Thanks for the test and the patch. I've pushed them to the master branch (d956b62 and 080e23d).
        Hide
        Uwe Kubosch added a comment -

        Thanks!

        Show
        Uwe Kubosch added a comment - Thanks!
        Hide
        Uwe Kubosch added a comment -

        Hi!

        Could you push the patch to the jruby-1_6 branch as well?

        I am experiencing a severe performance regression with JRuby 1.7.0.dev, and would very much like to revert to JRuby 1.6.6.dev if possible.

        Show
        Uwe Kubosch added a comment - Hi! Could you push the patch to the jruby-1_6 branch as well? I am experiencing a severe performance regression with JRuby 1.7.0.dev, and would very much like to revert to JRuby 1.6.6.dev if possible.
        Hide
        Hiro Asari added a comment -

        I cherry-picked them to the 1.6 branch: b087f3f and 4316fda.

        Show
        Hiro Asari added a comment - I cherry-picked them to the 1.6 branch: b087f3f and 4316fda.
        Hide
        Uwe Kubosch added a comment -

        Thanks!

        Show
        Uwe Kubosch added a comment - Thanks!

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Uwe Kubosch
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: