Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending query strings breaks URL #116

Closed
GoogleCodeExporter opened this issue Jul 5, 2015 · 11 comments
Closed

Appending query strings breaks URL #116

GoogleCodeExporter opened this issue Jul 5, 2015 · 11 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. create a rewrite rule like the one below:
    <rule>
        <from>^/robots\.txt$</from>
        <to type="permanent-redirect" last="true" qsappend="true">/en/robots.txt</to>
    </rule>

2. Go to a URL which will be rewritten with the above rule, and make sure to 
use a query-string
    www.mydomain.com/robots.txt?param1=value1&param2=value2

3. Check the rewritten URL

After the rewrite we would expect to see the following URL:
    www.mydomain.com/en/robots.txt?param1=value1&param2=value2
but the "?" before the first parameter has been replaced with a "&"
    www.mydomain.com/en/robots.txt&param1=value1&param2=value2

We are using version 4.0.3 and tested on several operating systems.

Currently we fixed it ourselves by changing the code:

Class: NormalRule.java
Method: public RewrittenUrl matches(final String url, final HttpServletRequest 
hsRequest, final HttpServletResponse hsResponse, RuleChain chain) ...

Original line of code (line 99)
    ruleExecutionOutput.setReplacedUrl(target + "&" + hsRequest.getQueryString());

New code
    if (target.contains("?")) {
        ruleExecutionOutput.setReplacedUrl(target + "&" + hsRequest.getQueryString());
    } else {
        ruleExecutionOutput.setReplacedUrl(target + "?" + hsRequest.getQueryString());
    }

Original issue reported on code.google.com by david.va...@gmail.com on 25 Jul 2012 at 11:57

Attachments:

@mperry
Copy link

mperry commented Oct 2, 2015

I have the same issue, 4.0.5 has not been released to Maven Central.

@bdw429s
Copy link
Contributor

bdw429s commented Dec 24, 2016

@paultuckey Update on this? Did this fix ever get released?

@bdw429s
Copy link
Contributor

bdw429s commented Dec 24, 2016

@paultuckey Found the commit from 2012 here: 8047d4f
Looks like it's in version 4.0.5 but Maven only has through 4.04. Is there a snapshot build somewhere we can point to?

@tirolerstefan
Copy link

We are using Atlassian Jira with Tuckey 4.0.3 and face this rewrite problem, too.
@paultuckey - are there plans for a next release? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants