Wicket
  1. Wicket
  2. WICKET-4891

UrlRenderer.renderRelativeUrl misbehavior if the filterPath is composed.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 6.3.0
    • Fix Version/s: 6.4.0
    • Component/s: wicket
    • Labels:
      None

      Description

      Using an application with a composed filterPath like:

      <filter-mapping>
      <filter-name>wicket.jsessionid</filter-name>
      <url-pattern>/demo/test/*</url-pattern>
      </filter-mapping>

      Wicket fails to properly render a bookmarkable link.

      I've debuged my app and the problem is here:

      UrlRenderer.removeCommonPrefixes()
      Line 309:

      String filterPath = request.getFilterPath();
      if (filterPath != null && segments.isEmpty() == false)
      {
      if (filterPath.equals(UrlUtils.normalizePath(segments.get(0))))
      {
      LOG.debug("Removing the filter path '{}' from '{}'", filterPath, segments);
      segments.remove(0);
      }
      }

      This code assumes that the filter path is a single segment path, not a composed path.

      I've only reached this bug browsing my website with the cookies disable. This is why it's not critical.

      1. WICKET-4891.tar.gz
        19 kB
        Jordi Deu-Pons
      2. WICKET-4891.patch
        13 kB
        Jordi Deu-Pons

        Activity

        Hide
        Jordi Deu-Pons added a comment -

        Minimal example demo application that fails if you browse it with the cookies disable

        Show
        Jordi Deu-Pons added a comment - Minimal example demo application that fails if you browse it with the cookies disable
        Hide
        Jordi Deu-Pons added a comment -

        I've created a pull request:
        https://github.com/apache/wicket/pull/22

        From the source code I can deduce that it can happen the same with the context path, so I also check this at the pull request.

        Show
        Jordi Deu-Pons added a comment - I've created a pull request: https://github.com/apache/wicket/pull/22 From the source code I can deduce that it can happen the same with the context path, so I also check this at the pull request.
        Hide
        Jordi Deu-Pons added a comment -

        A patch

        Show
        Jordi Deu-Pons added a comment - A patch
        Hide
        Sven Meier added a comment -

        I've just checked in a solution that uses fewer String concatenations and hopefully is easier to follow.

        #removeCommonPrefixes() now removes the whole prefix or nothing at all.

        For example say Wicket filter is registered on "filterPath" and the application has context "contextPath".
        Then it doesn't make sense to strip "filterPath" from the following url, since it doesn't contain "contextPath" at all:
        http://host:8080/filterPath/a/b;jsessionid=123456

        What do you think?

        Show
        Sven Meier added a comment - I've just checked in a solution that uses fewer String concatenations and hopefully is easier to follow. #removeCommonPrefixes() now removes the whole prefix or nothing at all. For example say Wicket filter is registered on "filterPath" and the application has context "contextPath". Then it doesn't make sense to strip "filterPath" from the following url, since it doesn't contain "contextPath" at all: http://host:8080/filterPath/a/b;jsessionid=123456 What do you think?
        Hide
        Jordi Deu-Pons added a comment -

        Yes, you are right it doesn't make sense to remove the "filterPath" if it doesn't contain "contextPath" at all.

        Show
        Jordi Deu-Pons added a comment - Yes, you are right it doesn't make sense to remove the "filterPath" if it doesn't contain "contextPath" at all.
        Hide
        Jordi Deu-Pons added a comment -

        Today I've checked with the last snapshot and everything it's working fine.

        Show
        Jordi Deu-Pons added a comment - Today I've checked with the last snapshot and everything it's working fine.
        Hide
        Sven Meier added a comment -

        compound filter and context paths are supported now

        Show
        Sven Meier added a comment - compound filter and context paths are supported now

          People

          • Assignee:
            Sven Meier
            Reporter:
            Jordi Deu-Pons
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development