开发者

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 c开发者_C百科annot 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.


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


http://en.wikipedia.org/wiki/Percent-encoding

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜