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:

@GoogleCodeExporter
Copy link
Author

I'm seeing the same thing...

This works:
<to type="redirect" last="true">http://localhost:8080/$2?%{query-string}</to>
While this does not:
<to type="redirect" qsappend="true" last="true">http://localhost:8080/$2</to>

This looked like a great feature and was actually the reason I upgraded from 
v3.2.

Also, I'd love to see this option work so that it only appends '?' when there 
is a query string to append.  This would help me clean up my rules that are 
duplicated just for this reason.

Original comment by raymond....@gmail.com on 30 Jul 2012 at 12:39

@GoogleCodeExporter
Copy link
Author

Fixed in trunk please verify.

Original comment by p...@tuckey.org on 31 Jul 2012 at 3:58

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Checked it, seems to be ok now!

Thanks for the quick fix!

Original comment by david.va...@gmail.com on 31 Jul 2012 at 7:27

@GoogleCodeExporter
Copy link
Author

Hi, any chance of seeing this issue in a release available via Maven Central? 
We're using some ugly workarounds right now w/ 4.0.4, and I'd love to see them 
go away...

Original comment by bengunnink on 19 Nov 2012 at 3:02

@GoogleCodeExporter
Copy link
Author

Greetings.

I'm using 4.0.4. version and I have exact problem - urlrewritefilter replaces ? 
with & . Is there any chance to make new version with that fix?

Many thanks.

Original comment by mario.ec...@gmail.com on 3 Apr 2014 at 2:29

@GoogleCodeExporter
Copy link
Author

Hi, all. The fix has not been released with 4.0.4. It is in trunk, but not in 
4.0.4 release. Release is needed.

Original comment by YLepik...@gmail.com on 14 May 2014 at 12:59

@GoogleCodeExporter
Copy link
Author

Two years later, still waiting for a new release fixing this issue... Is 
UrlRewriteFilter abandoned?

Original comment by christop...@gmail.com on 6 Aug 2014 at 3:56

@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