Skip to content

Commit 2d5f7e5

Browse files
committed
merge revision(s) r48666: [Backport ruby#10875]
* lib/uri/generic.rb (URI::Generic.build): use hostname= to detect and wrap IPv6 hosts. Build is accepting URI components and users may not expect that a host component needs to be wrapped with square brackets since it's not providing a URI. Note: initialize with arg_check => true does not wrap IPv6 hosts. by Joe Rafaniello <[email protected]> ruby#765 fix rubyGH-765 * test/uri/test_generic.rb: Add more tests git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 3457be5 commit 2d5f7e5

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Mon Mar 9 21:52:41 2015 NARUSE, Yui <[email protected]>
2+
3+
* lib/uri/generic.rb (URI::Generic.build):
4+
use hostname= to detect and wrap IPv6 hosts.
5+
Build is accepting URI components and users may not expect
6+
that a host component needs to be wrapped with square brackets
7+
since it's not providing a URI.
8+
Note: initialize with arg_check => true does not wrap IPv6 hosts.
9+
by Joe Rafaniello <[email protected]>
10+
https://github.com/ruby/ruby/pull/765 fix GH-765
11+
12+
* test/uri/test_generic.rb: Add more tests
13+
114
Tue Mar 3 02:42:27 2015 Eric Wong <[email protected]>
215

316
* ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX

lib/uri/generic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def initialize(scheme,
192192
if arg_check
193193
self.scheme = scheme
194194
self.userinfo = userinfo
195-
self.host = host
195+
self.hostname = host
196196
self.port = port
197197
self.path = path
198198
self.query = query

test/uri/test_generic.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,12 +741,26 @@ def test_ipv6
741741
end
742742

743743
def test_build
744-
URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil])
744+
u = URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil])
745+
assert_equal('http://example.com:80/foo', u.to_s)
746+
747+
u = URI::Generic.build(:scheme => "http", :host => "::1", :path => "/bar/baz")
748+
assert_equal("http://[::1]/bar/baz", u.to_s)
749+
assert_equal("[::1]", u.host)
750+
assert_equal("::1", u.hostname)
751+
752+
u = URI::Generic.build(:scheme => "http", :host => "[::1]", :path => "/bar/baz")
753+
assert_equal("http://[::1]/bar/baz", u.to_s)
754+
assert_equal("[::1]", u.host)
755+
assert_equal("::1", u.hostname)
745756
end
746757

747758
def test_build2
748-
URI::Generic.build2(path: "/foo bar/baz")
749-
URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil])
759+
u = URI::Generic.build2(path: "/foo bar/baz")
760+
assert_equal('/foo%20bar/baz', u.to_s)
761+
762+
u = URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil])
763+
assert_equal('http://example.com:80/foo%20bar', u.to_s)
750764
end
751765

752766
# 192.0.2.0/24 is TEST-NET. [RFC3330]

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.1.5"
2-
#define RUBY_RELEASE_DATE "2015-03-03"
3-
#define RUBY_PATCHLEVEL 306
2+
#define RUBY_RELEASE_DATE "2015-03-09"
3+
#define RUBY_PATCHLEVEL 307
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 3
7-
#define RUBY_RELEASE_DAY 3
7+
#define RUBY_RELEASE_DAY 9
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)