mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/uri/common.rb (escape): regard second argument as a character set. [ruby-dev:27692]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
03ab812585
commit
31f8181095
2 changed files with 10 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Nov 13 10:55:24 2005 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* lib/uri/common.rb (escape): regard second argument as a
|
||||
character set. [ruby-dev:27692]
|
||||
|
||||
Sat Nov 12 08:36:40 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* configure.in, eval.c, intern.h: check fd_mask type.
|
||||
|
|
|
@ -261,6 +261,7 @@ module URI
|
|||
# +unsafe+::
|
||||
# Regexp that matches all symbols that must be replaced with codes.
|
||||
# By default uses <tt>REGEXP::UNSAFE</tt>.
|
||||
# When this argument is a String, it represents a character set.
|
||||
#
|
||||
# == Description
|
||||
#
|
||||
|
@ -277,10 +278,13 @@ module URI
|
|||
# p URI.unescape(enc_uri)
|
||||
# # => "http://example.com/?a=\t\r"
|
||||
#
|
||||
# p URI.escape("@?@!", "!?")
|
||||
# # => "@%3F@%21"
|
||||
#
|
||||
def escape(str, unsafe = UNSAFE)
|
||||
unless unsafe.kind_of?(Regexp)
|
||||
# perhaps unsafe is String object
|
||||
unsafe = Regexp.new(Regexp.quote(unsafe), false, 'N')
|
||||
unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false, 'N')
|
||||
end
|
||||
str.gsub(unsafe) do |us|
|
||||
tmp = ''
|
||||
|
|
Loading…
Add table
Reference in a new issue