From a4645e56126cc8807fa66d1078d63447510623cf Mon Sep 17 00:00:00 2001 From: glass Date: Sat, 27 Sep 2014 03:13:22 +0000 Subject: * lib/uri/rfc3986_parser.rb: raise URI::InvalidURIError when uri doesn't respond to #to_str. [ruby-core:64453] [Bug #10150] * test/uri/test_parser.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/uri/rfc3986_parser.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index 965601c7b3..e23a3161f1 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -6,7 +6,11 @@ module URI RFC3986_relative_ref = /\A(?(?\/\/(?(?:(?(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?(?\[(?(?:\h{1,4}:){6}(?\h{1,4}:\h{1,4}|(?(?[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g\.\g\.\g))|::(?:\h{1,4}:){5}\g|\h{1,4}?::(?:\h{1,4}:){4}\g|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?v\h+\.[!$&-.0-;=A-Z_a-z~]+)\])|\g|(?(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?\d*))?)(?(?:\/(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?\/(?:(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g)*)?)|(?(?(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g)*)|(?))(?:\?(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?(?:\#(?(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/ def split(uri) #:nodoc: - uri = uri.to_str + begin + uri = uri.to_str + rescue NoMethodError + raise InvalidURIError, "bad URI(is not URI?): #{uri}" + end unless uri.ascii_only? raise InvalidURIError, "URI must be ascii only #{uri.dump}" end -- cgit v1.2.3