What's the difference between URI.escape and CGI.escape? this post was talking about replacing URI.escape with CGI::escape
as URI.escape has been obsolete. In our rails 3.2
app, URI.escape
was used for redirect_to
. Here is two cases in our rails app:
URI.escape(SUBURI + '/user_menus')
URI.escape(SUBURI + '/authentify/signin')
Here are the match in routes.rb
:
match '/signin', :to => 'authentify::sessions#new'
match '/user_menus', :to => 'user_menus#index'
match '/view_handler', :to => 'authentify::application#view_handler'
After replacing with CGI::escape
, there is error:
ERROR URI::InvalidURIError: the scheme http does not accept registry part:
After removing the CGI::escape
, the error disappears. Another example:
redirect_to CGI::escape(SUBURI + "/authentify/view_handler?index=0&msg=Insufficient Access Right! for action=#{action} and resource=#{resource}")
After replacing with CGI::escape, there is the error (as above).
What's wrong with the use of CGI::escape above? What's the exact equivalent of URI.escape? ? Also when will URI.escape be completely phased out?