Galen King
Galen King

Reputation: 762

Passing fullstops (periods) and forward slashes in a GET request?

I have built a form that submits values to Wufoo as a GET request in the URL. I cannot get it to work if any of the values (in a textarea) contain a line-break or a forward slash. Is there a way to encode these in a URL?

This is being done in Rails.

Upvotes: 4

Views: 1133

Answers (2)

coder_tim
coder_tim

Reputation: 1720

I thought Rails would do that for you. But if you need to do it manually, you can use CGI::escape, e.g.

 > require 'cgi'
 ...
 > CGI.escape("hello%there\nworld")
 => "hello%25there%0Aworld" 

EDIT: Actually, CGI does not seem to escape a dot. URI can be used instead, it takes an extra parameter that lets you list extra characters you want escaped:

URI.escape("hello.there%world", ".")

Upvotes: 2

Related Questions