Wicket
  1. Wicket
  2. WICKET-4907

UrlResourceReference generates broken relative URLs

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.7.0
    • Component/s: None
    • Labels:
      None

      Description

      I am trying to render a reference to a Javascript library which is stored somewhere in my webapp directory using UrlResourceReference:

      public void renderHead(IHeaderResponse response)

      { super.renderHead(response); response.render(JavaScriptHeaderItem.forReference(new UrlResourceReference(Url.parse("public/scripts/jquery-ui-1.8.6.custom.min.js")) .setContextRelative(true))); }

      This does not work, because our wicket servlet is using a prefix ("nui"), and thus the URL to the resource (corrently) contains ".." but this is escaped for some reason to "::".

      So the URL generated by the ResourceReference is e.g. "http://localhost:8080/app/nui/::/public/scripts/jquery-ui-1.8.6.custom.min.js" leading to a 404. The correct URL would be "http://localhost:8080/app/nui/../public/scripts/jquery-ui-1.8.6.custom.min.js" As far as I can see, ParentPathReferenceRewriter does the escaping.

      1. WICKET-4907.patch
        9 kB
        Martin Grigorov
      2. urlRenderInterface.patch
        5 kB
        Andrea Del Bene

        Activity

        Andreas Kappler created issue -
        Hide
        Martin Grigorov added a comment -

        See attachment 4903.tgz in WICKET-4903.
        Is this what you need as final result ?

        Show
        Martin Grigorov added a comment - See attachment 4903.tgz in WICKET-4903 . Is this what you need as final result ?
        Hide
        Andreas Kappler added a comment -

        Yes, this is excactly my use case.

        You can reproduce the behaviour i described if you change the web.xml line 30 of the quickstart to:

        <url-pattern>/context/*</url-pattern>

        Now the a.js incorrectly resolves to http://localhost:8080/context/js/a.js

        My expectation would be that setting setContextRelative(true) on TestResourceReference would solve the issue, but then it generates a very strange URL: "../../::/::/::/js/a.js"

        Show
        Andreas Kappler added a comment - Yes, this is excactly my use case. You can reproduce the behaviour i described if you change the web.xml line 30 of the quickstart to: <url-pattern>/context/*</url-pattern> Now the a.js incorrectly resolves to http://localhost:8080/context/js/a.js My expectation would be that setting setContextRelative(true) on TestResourceReference would solve the issue, but then it generates a very strange URL: "../../::/::/::/js/a.js"
        Martin Grigorov made changes -
        Field Original Value New Value
        Assignee Martin Grigorov [ mgrigorov ]
        Martin Grigorov made changes -
        Attachment WICKET-4907.patch [ 12570471 ]
        Andrea Del Bene made changes -
        Attachment urlRenderInterface.patch [ 12570836 ]
        Hide
        Martin Grigorov added a comment -

        UrlResourceReference has been improved to render its url as is. it wont be recalculated against the base url (the currently rendered page url).

        Show
        Martin Grigorov added a comment - UrlResourceReference has been improved to render its url as is. it wont be recalculated against the base url (the currently rendered page url).
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 6.7.0 [ 12323964 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        85d 1h 24m 1 Martin Grigorov 27/Feb/13 09:46

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Andreas Kappler
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development