views:

36

answers:

2

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.

Many thanks in advance,

Galen

A: 

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", ".")
Tim