Skip to content

Commit 28b9630

Browse files
authored
Merge pull request #114 from ruby/warn-compatibility-methods
Warn compatibility methods in RFC3986_PARSER
2 parents c2fdec0 + 898b889 commit 28b9630

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/uri/generic.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def self.build2(args)
8282
if args.kind_of?(Array)
8383
return self.build(args.collect{|x|
8484
if x.is_a?(String)
85-
DEFAULT_PARSER.escape(x)
85+
URI::RFC2396_PARSER.escape(x)
8686
else
8787
x
8888
end
@@ -91,7 +91,7 @@ def self.build2(args)
9191
tmp = {}
9292
args.each do |key, value|
9393
tmp[key] = if value
94-
DEFAULT_PARSER.escape(value)
94+
URI::RFC2396_PARSER.escape(value)
9595
else
9696
value
9797
end

lib/uri/rfc3986_parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,19 @@ def extract(str, schemes = nil, &block) # :nodoc:
147147

148148
# Compatibility for RFC2396 parser
149149
def make_regexp(schemes = nil) # :nodoc:
150+
warn "URI::RFC3986_PARSER.make_regexp is obsoleted. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
150151
RFC2396_PARSER.make_regexp(schemes)
151152
end
152153

153154
# Compatibility for RFC2396 parser
154155
def escape(str, unsafe = nil) # :nodoc:
156+
warn "URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
155157
unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
156158
end
157159

158160
# Compatibility for RFC2396 parser
159161
def unescape(str, escaped = nil) # :nodoc:
162+
warn "URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
160163
escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
161164
end
162165

test/uri/test_parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def test_raise_bad_uri_for_integer
6969
end
7070
end
7171

72-
def test_unescape
73-
p1 = URI::Parser.new
72+
def test_rfc2822_unescape
73+
p1 = URI::RFC2396_Parser.new
7474
assert_equal("\xe3\x83\x90", p1.unescape("\xe3\x83\x90"))
7575
assert_equal("\xe3\x83\x90", p1.unescape('%e3%83%90'))
7676
assert_equal("\u3042", p1.unescape('%e3%81%82'.force_encoding(Encoding::US_ASCII)))

0 commit comments

Comments
 (0)