End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
URI::RFC2396_Parser#escape
escape( str )
escape( str, unsafe )
lib/uri/rfc2396_parser.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/uri/rfc2396_parser.rb, line 287
def escape(str, unsafe = @regexp[:UNSAFE])
unless unsafe.kind_of?(Regexp)
# perhaps unsafe is String object
unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false)
end
str.gsub(unsafe) do
us = $&
tmp = ''
us.each_byte do |uc|
tmp << sprintf('%%%02X', uc)
end
tmp
end.force_encoding(Encoding::US_ASCII)
end
Args
Description
Constructs a safe String from str, removing unsafe characters, replacing them with codes.
See also
#convert_to_uri
#extract
.new
#initialize_pattern
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0