ruby-changes:34423
From: naruse <ko1@a...>
Date: Mon, 23 Jun 2014 12:18:57 +0900 (JST)
Subject: [ruby-changes:34423] naruse:r46504 (trunk): * lib/uri/generic.rb (check_port): allow strings for port= as
naruse 2014-06-23 12:18:51 +0900 (Mon, 23 Jun 2014) New Revision: 46504 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46504 Log: * lib/uri/generic.rb (check_port): allow strings for port= as described in rdoc. * lib/uri/rfc3986_parser.rb (regexp): implementation detail of above. Modified files: trunk/ChangeLog trunk/lib/uri/generic.rb trunk/lib/uri/rfc3986_parser.rb trunk/test/uri/test_generic.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 46503) +++ ChangeLog (revision 46504) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jun 23 12:01:42 2014 NARUSE, Yui <naruse@r...> + + * lib/uri/generic.rb (check_port): allow strings for port= as + described in rdoc. + + * lib/uri/rfc3986_parser.rb (regexp): implementation detail of above. + Mon Jun 23 11:35:01 2014 Nobuyoshi Nakada <nobu@r...> * eval.c (setup_exception): set backtrace in system stack error Index: lib/uri/rfc3986_parser.rb =================================================================== --- lib/uri/rfc3986_parser.rb (revision 46503) +++ lib/uri/rfc3986_parser.rb (revision 46504) @@ -84,7 +84,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/rfc3986_parser.rb#L84 QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~]|[\/?])*\z/, FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~]|[\/?])*\z/, OPAQUE: nil, - PORT: nil, + PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/, } end Index: lib/uri/generic.rb =================================================================== --- lib/uri/generic.rb (revision 46503) +++ lib/uri/generic.rb (revision 46504) @@ -683,7 +683,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L683 "can not set port with registry or opaque" elsif !v.kind_of?(Fixnum) && parser.regexp[:PORT] !~ v raise InvalidComponentError, - "bad component(expected port component): #{v}" + "bad component(expected port component): #{v.inspect}" end return true Index: test/uri/test_generic.rb =================================================================== --- test/uri/test_generic.rb (revision 46503) +++ test/uri/test_generic.rb (revision 46504) @@ -697,6 +697,14 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L697 assert_equal('http://foo:bar@baz', uri.to_s) assert_equal('zab', uri.host = 'zab') assert_equal('http://foo:bar@zab', uri.to_s) + uri.port = "" + assert_nil(uri.port) + uri.port = "80" + assert_equal(80, uri.port) + uri.port = "080" + assert_equal(80, uri.port) + uri.port = " 080 " + assert_equal(80, uri.port) assert_equal(8080, uri.port = 8080) assert_equal('http://foo:bar@zab:8080', uri.to_s) assert_equal('/', uri.path = '/') -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/