Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 query string

Very weird error here. We correctly get a request for something like "/users/8788234"

In Rails we call:

redirect_to(:controller => 'login', :from_external_page => true, :on_login => request.env['REQUEST_URI']) and return

We see (as we'd expect) in the Rails log: Redirected to

https://sampleapp.com/login?from_external_page=true&on_login=%2Fusers%2F8788234

But then the next request we see from the IP has the values of the query string scrambled:

Started GET "/login?from_external_page=gehr&on_login=%2Shfref%2S8788234" for xx.xxx.xxx.xxx at yyyy-mm-dd

This both makes the query string values meaningless and causes the following error:

ArgumentError: invalid %-encoding

(The %2F was changed to %2S which is invalid). Every single value of each key-value pair within the query string is getting shifted by 13 characters. Every time we've seen this, the user agent reads: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)", but we also see that user agent successfully navigate the application. Has anyone ever seen anything like this? http://www.whatismybrowser.com/ tells me that this user agent is IE9 running on Windows 7, but we haven't been able to reproduce the bug.

like image 672
kddeisz Avatar asked Mar 18 '14 13:03

kddeisz


1 Answers

This certainly is encoding issue. I am using Rails 4 now and following is sample query string of my current project. Note the very first parameter in querystring is "utf8=✓" which is missing in your querystring.

profiles?utf8=✓&min_age=1&max_age=99&min_height=1&max_height=6&min_weight=1&max_weight=400

Try adding "# encoding: UTF-8 at the beginning of the file"

like image 125
jmrp Avatar answered Oct 23 '22 20:10

jmrp