Wicket
  1. Wicket
  2. WICKET-5098

PackageResourceBlockedException under Windows for *.js files in web app's own packages, not in jars

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.6.0
    • Fix Version/s: 6.7.0
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      Windows 7

      Description

      PackageResourceGuard.acceptAbsolutePath() uses '/' instead of File.separator when manipulating absolute file paths. This causes problems on MS-Windows when trying to parse "C:\com\mycompany\...." resulting in exceptions when trying to load javascript etc files that are not in a jar. The problem shows up for resources accessed via FileResourceStream, but not UrlResourceStream.

      org.apache.wicket.request.resource.PackageResource$PackageResourceBlockedException: Access denied to (static) package resource com/mycompany/components/behavior/TinyMceBehavior.js. See IPackageResourceGuard
      at org.apache.wicket.request.resource.PackageResource.internalGetResourceStream(PackageResource.java:460)
      at org.apache.wicket.request.resource.PackageResource.getCacheableResourceStream(PackageResource.java:395)
      at org.apache.wicket.request.resource.PackageResource.getCacheKey(PackageResource.java:223)
      at org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion.getVersion(RequestCycleCachedResourceVersion.java:81)

        Activity

        Hide
        Jenny Brown added a comment -

        Possible fix attached.

        Show
        Jenny Brown added a comment - Possible fix attached.
        Hide
        Sven Meier added a comment -

        PackageResourceGuard#acceptAbsolutePath(String) line #148:

        if (!absolute.contains(File.spearator))

        { return false; }

        This returns false for jar packaged resources on Windows.

        Show
        Sven Meier added a comment - PackageResourceGuard#acceptAbsolutePath(String) line #148: if (!absolute.contains(File.spearator)) { return false; } This returns false for jar packaged resources on Windows.
        Hide
        Igor Vaynberg added a comment -

        what does such a path look like? i dont have windows so im fixing this somewhat in the dark...

        Show
        Igor Vaynberg added a comment - what does such a path look like? i dont have windows so im fixing this somewhat in the dark...
        Hide
        Sven Meier added a comment -

        Just the usual path for resources inside of jar files e.g.

        org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js

        Forward slashes but no Windows file separator contained -> return false

        Show
        Sven Meier added a comment - Just the usual path for resources inside of jar files e.g. org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js Forward slashes but no Windows file separator contained -> return false
        Hide
        Igor Vaynberg added a comment -

        thats not a usual path on windows since it uses a linux style file separator instead of windows i believe i got it fixed, test it and reopen if its still broken.

        Show
        Igor Vaynberg added a comment - thats not a usual path on windows since it uses a linux style file separator instead of windows i believe i got it fixed, test it and reopen if its still broken.
        Hide
        Sven Meier added a comment -

        Perhaps we could normalize to path a little bit earlier? But it works fine now.

        Show
        Sven Meier added a comment - Perhaps we could normalize to path a little bit earlier? But it works fine now.

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Jenny Brown
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development