提交 5d773f8d 编写于 作者: E Emilio Tagua

Remove warning "URI.unescape is obsolete" from actionpack.

上级 535371e9
......@@ -161,7 +161,11 @@ def initialize(controller, options = {}, infer_extension = true)
def normalize!(path)
path << 'index' if path[-1] == ?/
path << ".#{extension}" if extension and !path.ends_with?(extension)
URI.unescape(path)
uri_parser.unescape(path)
end
def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
end
......
......@@ -99,7 +99,7 @@ def caches_page(*actions)
private
def page_cache_file(path)
name = (path.empty? || path == "/") ? "/index" : URI.unescape(path.chomp('/'))
name = (path.empty? || path == "/") ? "/index" : uri_parser.unescape(path.chomp('/'))
name << page_cache_extension unless (name.split('/').last || name).include? '.'
return name
end
......@@ -111,6 +111,10 @@ def page_cache_path(path)
def instrument_page_cache(name, path)
ActiveSupport::Notifications.instrument("#{name}.action_controller", :path => path){ yield }
end
def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
# Expires the page that was cached with the +options+ as a key. Example:
......
......@@ -127,7 +127,11 @@ def initialize(env = {})
class Result < ::Array #:nodoc:
def to_s() join '/' end
def self.new_escaped(strings)
new strings.collect {|str| URI.unescape str}
new strings.collect {|str| uri_parser.unescape str}
end
def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
......
......@@ -395,10 +395,10 @@ def map_method(method, *args, &block)
# namespace "admin" do
# resources :posts, :comments
# end
#
#
# This will create a number of routes for each of the posts and comments
# controller. For Admin::PostsController, Rails will create:
#
#
# GET /admin/photos
# GET /admin/photos/new
# POST /admin/photos
......@@ -406,33 +406,33 @@ def map_method(method, *args, &block)
# GET /admin/photos/1/edit
# PUT /admin/photos/1
# DELETE /admin/photos/1
#
#
# If you want to route /photos (without the prefix /admin) to
# Admin::PostsController, you could use
#
#
# scope :module => "admin" do
# resources :posts, :comments
# end
#
# or, for a single case
#
#
# resources :posts, :module => "admin"
#
#
# If you want to route /admin/photos to PostsController
# (without the Admin:: module prefix), you could use
#
#
# scope "/admin" do
# resources :posts, :comments
# end
#
# or, for a single case
#
#
# resources :posts, :path => "/admin"
#
# In each of these cases, the named routes remain the same as if you did
# not use scope. In the last case, the following paths map to
# PostsController:
#
#
# GET /admin/photos
# GET /admin/photos/new
# POST /admin/photos
......
......@@ -66,7 +66,11 @@ def merge_default_action!(params)
end
def split_glob_param!(params)
params[@glob_param] = params[@glob_param].split('/').map { |v| URI.unescape(v) }
params[@glob_param] = params[@glob_param].split('/').map { |v| uri_parser.unescape(v) }
end
def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
......@@ -543,7 +547,7 @@ def recognize_path(path, environment = {})
params.each do |key, value|
if value.is_a?(String)
value = value.dup.force_encoding(Encoding::BINARY) if value.encoding_aware?
params[key] = URI.unescape(value)
params[key] = uri_parser.unescape(value)
end
end
......@@ -560,6 +564,10 @@ def recognize_path(path, environment = {})
end
private
def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
def handle_positional_args(options)
return unless args = options.delete(:_positional_args)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册