lib/rack/utils.rb in rack-2.2.9 vs lib/rack/utils.rb in rack-2.2.10
- old
+ new
@@ -22,10 +22,11 @@
COMMON_SEP = QueryParser::COMMON_SEP
KeySpaceConstrainedParams = QueryParser::Params
RFC2822_DAY_NAME = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]
RFC2822_MONTH_NAME = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
+ RFC2396_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
class << self
attr_accessor :default_query_parser
end
# The default number of bytes to allow parameter keys to take up.
@@ -40,17 +41,17 @@
end
# Like URI escaping, but with %20 instead of +. Strictly speaking this is
# true URI escaping.
def escape_path(s)
- ::URI::DEFAULT_PARSER.escape s
+ RFC2396_PARSER.escape s
end
# Unescapes the **path** component of a URI. See Rack::Utils.unescape for
# unescaping query parameters or form components.
def unescape_path(s)
- ::URI::DEFAULT_PARSER.unescape s
+ RFC2396_PARSER.unescape s
end
# Unescapes a URI escaped string with +encoding+. +encoding+ will be the
# target encoding of the string returned, and it defaults to UTF-8
def unescape(s, encoding = Encoding::UTF_8)
@@ -379,10 +380,10 @@
end
end
ranges << (r0..r1) if r0 <= r1
end
- return [] if ranges.map(&:size).sum > size
+ return [] if ranges.map(&:size).inject(0, :+) > size
ranges
end
# Constant time string comparison.