Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn compatibility methods in RFC3986_PARSER #114

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/uri/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def self.build2(args)
if args.kind_of?(Array)
return self.build(args.collect{|x|
if x.is_a?(String)
DEFAULT_PARSER.escape(x)
URI::RFC2396_PARSER.escape(x)
else
x
end
Expand All @@ -91,7 +91,7 @@ def self.build2(args)
tmp = {}
args.each do |key, value|
tmp[key] = if value
DEFAULT_PARSER.escape(value)
URI::RFC2396_PARSER.escape(value)
else
value
end
Expand Down
3 changes: 3 additions & 0 deletions lib/uri/rfc3986_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,19 @@ def extract(str, schemes = nil, &block) # :nodoc:

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions test/uri/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_raise_bad_uri_for_integer
end
end

def test_unescape
p1 = URI::Parser.new
def test_rfc2822_unescape
p1 = URI::RFC2396_Parser.new
assert_equal("\xe3\x83\x90", p1.unescape("\xe3\x83\x90"))
assert_equal("\xe3\x83\x90", p1.unescape('%e3%83%90'))
assert_equal("\u3042", p1.unescape('%e3%81%82'.force_encoding(Encoding::US_ASCII)))
Expand Down