summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-23 03:18:51 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-23 03:18:51 +0000
commite02eb253e7a31f4767eecd8d55a62e5a5608b74a (patch)
treed0402911b04cf1515a5eefab193c12e14be67bbd
parent66aba8cca29d250667ec0830cca77a9b021745cc (diff)
* lib/uri/generic.rb (check_port): allow strings for port= as
described in rdoc. * lib/uri/rfc3986_parser.rb (regexp): implementation detail of above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--lib/uri/generic.rb2
-rw-r--r--lib/uri/rfc3986_parser.rb2
-rw-r--r--test/uri/test_generic.rb8
4 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 700e8c26ad..450dc7e477 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Jun 23 12:01:42 2014 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* eval.c (setup_exception): set backtrace in system stack error
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index b924f53cd7..7fbe5ff396 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -683,7 +683,7 @@ module URI
"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
diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb
index cd95ab8860..aa74e11eb4 100644
--- a/lib/uri/rfc3986_parser.rb
+++ b/lib/uri/rfc3986_parser.rb
@@ -84,7 +84,7 @@ module URI
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
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb
index 398c4cc830..977ae72250 100644
--- a/test/uri/test_generic.rb
+++ b/test/uri/test_generic.rb
@@ -697,6 +697,14 @@ class URI::TestGeneric < Test::Unit::TestCase
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 = '/')