summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-09 13:00:13 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-09 13:00:13 +0000
commit2d5f7e5e17ef2a05b4218d7a889453897afa72be (patch)
tree657f8979709a9ca347e7218554f7f3ef00f34779
parent3457be5f12b950953f10b5685316fa86a9ac466c (diff)
merge revision(s) r48666: [Backport #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 <jrafanie@redhat.com> https://github.com/ruby/ruby/pull/765 fix GH-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
-rw-r--r--ChangeLog13
-rw-r--r--lib/uri/generic.rb2
-rw-r--r--test/uri/test_generic.rb20
-rw-r--r--version.h6
4 files changed, 34 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index f06e6aab0c..30ae55d9d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Mon Mar 9 21:52:41 2015 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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 <jrafanie@redhat.com>
+ https://github.com/ruby/ruby/pull/765 fix GH-765
+
+ * test/uri/test_generic.rb: Add more tests
+
Tue Mar 3 02:42:27 2015 Eric Wong <e@80x24.org>
* ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 88c96fe90a..d7a55dcbd8 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -192,7 +192,7 @@ module URI
if arg_check
self.scheme = scheme
self.userinfo = userinfo
- self.host = host
+ self.hostname = host
self.port = port
self.path = path
self.query = query
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb
index b5b1fc1c26..c9e3576a80 100644
--- a/test/uri/test_generic.rb
+++ b/test/uri/test_generic.rb
@@ -741,12 +741,26 @@ class URI::TestGeneric < Test::Unit::TestCase
end
def test_build
- URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil])
+ u = URI::Generic.build(['http', nil, 'example.com', 80, nil, '/foo', nil, nil, nil])
+ assert_equal('http://example.com:80/foo', u.to_s)
+
+ u = URI::Generic.build(:scheme => "http", :host => "::1", :path => "/bar/baz")
+ assert_equal("http://[::1]/bar/baz", u.to_s)
+ assert_equal("[::1]", u.host)
+ assert_equal("::1", u.hostname)
+
+ u = URI::Generic.build(:scheme => "http", :host => "[::1]", :path => "/bar/baz")
+ assert_equal("http://[::1]/bar/baz", u.to_s)
+ assert_equal("[::1]", u.host)
+ assert_equal("::1", u.hostname)
end
def test_build2
- URI::Generic.build2(path: "/foo bar/baz")
- URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil])
+ u = URI::Generic.build2(path: "/foo bar/baz")
+ assert_equal('/foo%20bar/baz', u.to_s)
+
+ u = URI::Generic.build2(['http', nil, 'example.com', 80, nil, '/foo bar' , nil, nil, nil])
+ assert_equal('http://example.com:80/foo%20bar', u.to_s)
end
# 192.0.2.0/24 is TEST-NET. [RFC3330]
diff --git a/version.h b/version.h
index 83954470ca..d9600bb35b 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.5"
-#define RUBY_RELEASE_DATE "2015-03-03"
-#define RUBY_PATCHLEVEL 306
+#define RUBY_RELEASE_DATE "2015-03-09"
+#define RUBY_PATCHLEVEL 307
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 3
+#define RUBY_RELEASE_DAY 9
#include "ruby/version.h"