* lib/uri/common.rb (URI::Parser#initialize_regexp):

use \A \z instead of ^ $. [Bug #5843]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-01-05 02:57:21 +00:00
Родитель 4157d6f2f3
Коммит 87fe448091
3 изменённых файлов: 16 добавлений и 10 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Thu Jan 5 11:47:54 2012 NARUSE, Yui <naruse@ruby-lang.org>
* lib/uri/common.rb (URI::Parser#initialize_regexp):
use \A \z instead of ^ $. [Bug #5843]
Wed Jan 4 17:55:53 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com> Wed Jan 4 17:55:53 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
* array.c (rb_ary_sample): add example for Array#sample * array.c (rb_ary_sample): add example for Array#sample

Просмотреть файл

@ -514,16 +514,16 @@ module URI
ret[:UNSAFE] = Regexp.new("[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]") ret[:UNSAFE] = Regexp.new("[^#{pattern[:UNRESERVED]}#{pattern[:RESERVED]}]")
# for Generic#initialize # for Generic#initialize
ret[:SCHEME] = Regexp.new("^#{pattern[:SCHEME]}$") ret[:SCHEME] = Regexp.new("\\A#{pattern[:SCHEME]}\\z")
ret[:USERINFO] = Regexp.new("^#{pattern[:USERINFO]}$") ret[:USERINFO] = Regexp.new("\\A#{pattern[:USERINFO]}\\z")
ret[:HOST] = Regexp.new("^#{pattern[:HOST]}$") ret[:HOST] = Regexp.new("\\A#{pattern[:HOST]}\\z")
ret[:PORT] = Regexp.new("^#{pattern[:PORT]}$") ret[:PORT] = Regexp.new("\\A#{pattern[:PORT]}\\z")
ret[:OPAQUE] = Regexp.new("^#{pattern[:OPAQUE_PART]}$") ret[:OPAQUE] = Regexp.new("\\A#{pattern[:OPAQUE_PART]}\\z")
ret[:REGISTRY] = Regexp.new("^#{pattern[:REG_NAME]}$") ret[:REGISTRY] = Regexp.new("\\A#{pattern[:REG_NAME]}\\z")
ret[:ABS_PATH] = Regexp.new("^#{pattern[:ABS_PATH]}$") ret[:ABS_PATH] = Regexp.new("\\A#{pattern[:ABS_PATH]}\\z")
ret[:REL_PATH] = Regexp.new("^#{pattern[:REL_PATH]}$") ret[:REL_PATH] = Regexp.new("\\A#{pattern[:REL_PATH]}\\z")
ret[:QUERY] = Regexp.new("^#{pattern[:QUERY]}$") ret[:QUERY] = Regexp.new("\\A#{pattern[:QUERY]}\\z")
ret[:FRAGMENT] = Regexp.new("^#{pattern[:FRAGMENT]}$") ret[:FRAGMENT] = Regexp.new("\\A#{pattern[:FRAGMENT]}\\z")
ret ret
end end

Просмотреть файл

@ -692,6 +692,7 @@ class URI::TestGeneric < Test::Unit::TestCase
uri = URI.parse('http://example.com') uri = URI.parse('http://example.com')
assert_raise(URI::InvalidURIError) { uri.password = 'bar' } assert_raise(URI::InvalidURIError) { uri.password = 'bar' }
assert_raise(URI::InvalidComponentError) { uri.query = "foo\nbar" }
uri.userinfo = 'foo:bar' uri.userinfo = 'foo:bar'
assert_equal('http://foo:bar@example.com', uri.to_s) assert_equal('http://foo:bar@example.com', uri.to_s)
assert_raise(URI::InvalidURIError) { uri.registry = 'bar' } assert_raise(URI::InvalidURIError) { uri.registry = 'bar' }