BookmarkablePageLink renderes bogus relative URLs to non-mounted pages
----------------------------------------------------------------------

                 Key: WICKET-3094
                 URL: https://issues.apache.org/jira/browse/WICKET-3094
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 1.4.12
            Reporter: Sven Meier


Example:
- page Foo is mounted under "foo", displayed in the browser under the following 
URL:

        http://localhost:8080/foo

- page Foo contains a BookmarkablePageLink to a non-mounted page Bar, thus 
resulting in the following markup:

        <a href="?wicket:bookmarkablePage=:Bar">link</a>

- if the user clicks the link, the browser will load the following URL:

        http://localhost:8080/foo?wicket:bookmarkablePage=:Bar

IMHO the resulting URL is bogus for the following reasons:
- the bookmark is polluted with the "foo" prefix, although page Bar has nothing 
to do with "foo"
- if page Bar contains a form and the session expires while the user is on page 
Bar, Wicket will instantiate page Foo to try a  
BookmarkableListenerInterfaceRequestTarget (which will probably fail or even 
worse will perform something unexpected)

Interesting enough all goes well if page Foo is mounted under "mounts/foo", as 
the resulting markup's URL contains a "../" prefix:

        <a href="../?wicket:bookmarkablePage=:Bar">link</a>

IMHO it's important for a link to page Bar to step out of the "foo" context, 
the following patch solves the problem by prefixing a dot ("."):

Index: 
src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java
===================================================================
--- 
src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java
 (revision 1004354)
+++ 
src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java
 (working copy)
@@ -778,6 +778,7 @@
        {
                // Begin encoding URL
                final AppendingStringBuffer url = new AppendingStringBuffer(64);
+               url.append(".");
 
                // Get page Class
                final Class<? extends Page> pageClass = 
requestTarget.getPageClass();

Please evaluate.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to