[BLOSSOM-196] Duplicate request parameters after rewrite Created: 26/Nov/14  Updated: 28/Nov/14  Resolved: 28/Nov/14

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: 2.0.5
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: TLN Assignee: Tobias Mattsson
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Hello there,

I'm not sure this bug is caused by Blossom, but some investigation with the Java debugger indicated that this is the best first guess. If I'm wrong, then sorry, please forward it.

In order to reproduce, please add this class to any Blossom project:

@Controller
@Template(id=DummyTemplate.TEMPLATE_ID, title="Dummy Page")
@RequestMapping(value="/dummypage")
public class DummyTemplate
{
	public static final String TEMPLATE_ID="rr:pages/dummypage";
	
	@RequestMapping(method=RequestMethod.GET)
	public @ResponseBody String handleRequest(HttpServletRequest request, @RequestParam(value="dummyparam") String dummyParam)
	{
		return "dummy param value: '"+dummyParam+"'";
	}
}

Now create a website called /dummy.html having this template and open
/dummy.html?dummyparam=xyz
in your browser.
It prints this:
dummy param value: 'xyz'
This is correct.

Now, please create rewrite rule like this:
class: info.magnolia.cms.beans.config.RegexpVirtualURIMapping
fromURI: /dummy2((?.*)?)$
(Please mind the backslash, Jira is not displaying it correctly unless in source view. I don't know how to escape it correctly)
toURI: forward:/dummy.html$1

Then open
/dummy2?dummyparam=xyz
in your browser.
It should also print:
dummy param value: 'xyz'
However it prints this:
dummy param value: 'xyz,xyz'
Which is the bug.

Thanks for looking into it.

PS: Platform is Tomcat 8 here. If this changes anything.



 Comments   
Comment by TLN [ 27/Nov/14 ]

Hi again,

it has shown now that this is not a bug but unexpected rewrite behaviour: Although you can match URL parameters in your regex and you can append them to the rewritten URL, any incoming GET parameters are already automatically passed on, so if you do that again as part of your rule, you get duplicates.

This can be closed, please.

Comment by Tobias Mattsson [ 28/Nov/14 ]

This is standard servlet container behavior. When you forward with a query string those parameters are added to those already present. Modify your regex so it doesnt add the query string.

Generated at Sun Feb 11 23:31:06 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.