You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Sven Meier (JIRA)" <ji...@apache.org> on 2010/10/05 14:26:33 UTC

[jira] Created: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

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.


[jira] Commented: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12918624#action_12918624 ] 

Sven Meier commented on WICKET-3094:
------------------------------------

Having thought again about this issue, it seems to me that all query-string-only URLs would benefit from a leading 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)
@@ -372,6 +372,12 @@
 				// Servlet/Filter, with no leading '/'.
 				PrependingStringBuffer prepender = new PrependingStringBuffer(url.toString());
 
+				// We need to special-case links containing query string only
+				if (url.length() > 0 && url.charAt(0) == '?')
+				{
+					prepender.prepend('.');
+				}
+
 				// Prepend prefix to the URL to make it relative to the current
 				// request.
 				prepender.prepend(requestCycle.getRequest().getRelativePathPrefixToWicketHandler());


> 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.


[jira] Commented: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12921607#action_12921607 ] 

Hudson commented on WICKET-3094:
--------------------------------

Integrated in Apache Wicket 1.4.x #208 (See [https://hudson.apache.org/hudson/job/Apache%20Wicket%201.4.x/208/])
    

> 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
>            Assignee: Igor Vaynberg
>
> 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.


[jira] Commented: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12918436#action_12918436 ] 

Sven Meier commented on WICKET-3094:
------------------------------------

IE and FF work fine with the proposed change. WebRequestCodingStrategyTest has to be adjusted for the leading ".".
Not sure about implications to BookmarkableListenerInterfaceRequestTarget though.

> 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.


[jira] Resolved: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-3094.
-----------------------------------

    Resolution: Won't Fix
      Assignee: Igor Vaynberg

done

> 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
>            Assignee: Igor Vaynberg
>
> 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.


[jira] Commented: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

Posted by "Sven Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12921236#action_12921236 ] 

Sven Meier commented on WICKET-3094:
------------------------------------

Thanks for your time evaluating this issue, I'll retry with 1.5.x.

Regarding 1.4.x:
Could we make this adjustment optional then? WebRequestCodingStrategy#encode() is final so subclassing would imply duplicating a lot of code for me.

> 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.


[jira] Commented: (WICKET-3094) BookmarkablePageLink renderes bogus relative URLs to non-mounted pages

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12921007#action_12921007 ] 

Igor Vaynberg commented on WICKET-3094:
---------------------------------------

actually some users depend on this wonky behavior in 1.4.x so we wont be changing it. in 1.5.x its already properly fixed afaik.

> 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.