Jimish Jobanputra
2010-Dec-31 23:52 UTC
Parsing params (one of the params value has ampersand)
Hello, I am trying to parse a URL of this format http://example.com/links?deal_id=161&url=http://another_example.com/index.php?route=product/product&product_id=275 I need to get 2 params deal_id and url However, in the above example, if I do params[:url], then I get "http://another_example.com/index.php?route=product/product" product_id=275 is dropped on the floor as its considered another params.... CGI:escape for url is not an option since I have no choice in what I am being passed... Any ideas? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2011-Jan-01 00:23 UTC
Re: Parsing params (one of the params value has ampersand)
On Fri, Dec 31, 2010 at 3:52 PM, Jimish Jobanputra <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am trying to parse a URL of this format > > http://example.com/links?deal_id=161&url=http://another_example.com/index.php?route=product/product&product_id=275 > > I need to get 2 params > > deal_id and url > > However, in the above example, if I do params[:url], then I get > "http://another_example.com/index.php?route=product/product" > > product_id=275 is dropped on the floor as its considered another > params.... > > CGI:escape for url is not an option since I have no choice in what I am > being passed... > > Any ideas?1) Parse the entire query string yourself instead of using the params hash 2) Explicitly retrieve params[''product_id''] and (re)build the url param as you need it in the controller. 3) Fix the request (as in #2) in a Rack middleware filter. 4) Tell the "no-choice" source of these malformed unescaped URLs to read the damn RFCs :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.