Which one to use? URI.escape or CGI.escape? Lets look at irb:
>> URI.escape('Test <>?/&;=:.')
=> "Test%20%3C%3E?/&;=:."
>> CGI.escape('Test <>?/&;=:.')
=> "Test+%3C%3E%3F%2F%26%3B%3D%3A."
CGI.escape is looking better but it does not escape dots which gives "RoutingError No route matches". Here is the solution working for me
>> test = URI.escape(CGI.escape('Test <>?/&;=:.'),'.')
=> "Test+%3C%3E%3F%2F%26%3B%3D%3A%2E"
>> CGI.unescape(test)
=> "Test <>?/&;=:."
Friday, October 10, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment