[MGNLSTK-1366] Allow query parameters to be used in redirect template Created: 05/Mar/14  Updated: 29/Sep/14  Resolved: 17/Sep/14

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: None
Affects Version/s: 2.7.2
Fix Version/s: 2.7.9, 2.8.4

Type: Bug Priority: Neutral
Reporter: Richard Gange Assignee: Christopher Zimmermann
Resolution: Fixed Votes: 0
Labels: support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
causality
dependency
depends upon MAGNOLIA-5914 Update TemplatingFunctions to support... Closed
Template:
Acceptance criteria:
Empty
Release notes required:
Yes
Date of First Response:

 Description   

The redirect template should allow for query parameters in the path property. The issue right now is that the '&' character is being encoded to &

Steps to reproduce:
1. Create a new page that uses the redirect template
2. Edit the page properties to use a path like: http://www.magnolia-cms.com/?param1=x&param2=y
3. Preview the page outside of magnolia and observe the URL is encoded



 Comments   
Comment by Richard Gange [ 05/Mar/14 ]

I was able to solve the issue by unescaping html on the redirectTo variable on line 114. Like this:

webContext.getResponse().sendRedirect(StringEscapeUtils.unescapeHtml(redirectTo));

This seems to completely fixes the external link but the internal link needs some additional changes in the ftl to handle the query parameters. Since in the ftl we check to see that a content node exists for the provided path. The addition of the query parameters on the end of the path will break the check.

Comment by Richard Gange [ 10/Mar/14 ]

Christian has suggested a solution that only involves changing the template script. See SUPPORT-3307.

Comment by Christopher Zimmermann [ 10/Sep/14 ]

Update RedirectTemplateModel to pay attention to querystrings - the most important thing being to call EscapeUtil.unescapeXss on the redirect url's so that the & in a querystring gets converted back to &, etc.

Additionally support querystring in internal links by improving getRedirectPathToInternalContent to strip the querystring off before checking if the node exists.

Generated at Mon Feb 12 07:35:54 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.