You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Erik van Oosten (JIRA)" <ji...@apache.org> on 2008/09/04 14:01:44 UTC

[jira] Commented: (WICKET-847) setResponsePage redirects to wrong url

    [ https://issues.apache.org/jira/browse/WICKET-847?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12628320#action_12628320 ] 

Erik van Oosten commented on WICKET-847:
----------------------------------------

I got bitten by this as well (with 1.4-m3).

The failing combination is: Tomcat and IE (6 or 7).

Firefox correctly interprets the "./" as "" so its okay to use Firefox + Tomcat.
Jetty converts "./" to "", so its okay to use any borwser on Jetty.

My patch is:

In BookmarkablePageRequestTarget:
	public void respond(RequestCycle requestCycle)
	{
		if (pageClassRef != null && pageClassRef.get() != null)
		{
			if (requestCycle.isRedirect())
			{
				IRequestCycleProcessor processor = requestCycle.getProcessor();
				String redirectUrl = processor.getRequestCodingStrategy()
					.encode(requestCycle, this)
					.toString();
// START OF PATCH
                if (redirectUrl.startsWith("./")) {
                    redirectUrl = redirectUrl.substring(2);
                }
// END OF PATCH
                requestCycle.getResponse().redirect(redirectUrl);
			}
			else
			{
				// Let the page render itself
				getPage(requestCycle).renderPage();
			}
		}
	}


And in RedirectRequestTarget:
	public void respond(RequestCycle requestCycle)
	{
		Response response = requestCycle.getResponse();
		response.reset();
		if (redirectUrl.startsWith("/"))
		{
			RequestContext rc = RequestContext.get();
			if (rc.isPortletRequest() && ((PortletRequestContext)rc).isEmbedded())
			{
				response.redirect(redirectUrl);
			}
			else
			{
                String location = RequestCycle.get()
                        .getRequest()
                        .getRelativePathPrefixToContextRoot() +
                        this.redirectUrl.substring(1);
// START OF PATCH
                if (location.startsWith("./")) {
                    location = location.substring(2);
                }
// END OF PATCH
                response.redirect(location);
			}
		}
		else if (redirectUrl.startsWith("http://") || redirectUrl.startsWith("https://"))
		{
			response.redirect(redirectUrl);
		}
		else
		{
			response.redirect(RequestCycle.get()
				.getRequest()
				.getRelativePathPrefixToWicketHandler() +
				redirectUrl);
		}
	}


> setResponsePage redirects to wrong url
> --------------------------------------
>
>                 Key: WICKET-847
>                 URL: https://issues.apache.org/jira/browse/WICKET-847
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.0-beta2
>            Reporter: Andrew Klochkov
>            Assignee: Alastair Maw
>             Fix For: 1.3.5
>
>         Attachments: wicket-quickstart.tar.gz
>
>
> When I do setResponsePage(MyHomePage.class) IE tries to show me "my.site.com/./" url and gets 404 response. 
> Firefox just shows "my.site.com" without any troubles. I'm using wicket 1.3-beta2 and WicketFilter mapped to /*. 
> It's being reproduced under tomcat only, jetty works fine. My tomcat version is 5.5.17. 
> Quickstart project which reproduces the bug is attached.

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