diff options
author | akira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-02-23 06:08:29 +0000 |
---|---|---|
committer | akira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-02-23 06:08:29 +0000 |
commit | 616a75e7e3db6a6c343f292e19d5afd531a2dc00 (patch) | |
tree | 8d47afc558ca6b160bba83fbe5a74077e5a9e71e | |
parent | d805a0d0766c7422e25886ee6282d85eaff26b5b (diff) |
* lib/uri/generic.rb (split_userinfo): should split ":pass" into ""
and "pass". [ruby-dev:25667]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/uri/generic.rb | 9 | ||||
-rw-r--r-- | test/uri/test_generic.rb | 17 |
3 files changed, 22 insertions, 9 deletions
@@ -1,3 +1,8 @@ +Thu Feb 23 15:04:32 2005 akira yamada <akira@ruby-lang.org> + + * lib/uri/generic.rb (split_userinfo): should split ":pass" into "" + and "pass". [ruby-dev:25667] + Wed Feb 23 01:57:46 2005 Shugo Maeda <shugo@ruby-lang.org> * lib/net/imap.rb (initialize): handle certs correctly. Thanks, diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 0dedcf494a..3253450046 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -343,14 +343,7 @@ module URI def split_userinfo(ui) return nil, nil unless ui - tmp = ui.index(':') - if tmp - user = ui[0..tmp - 1] - password = ui[tmp + 1..-1] - else - user = ui - password = nil - end + user, password = ui.split(/:/, 2) return user, password end diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index 8740574e4e..8a7feb4982 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -117,11 +117,26 @@ class TestGeneric < Test::Unit::TestCase assert_raises(URI::InvalidURIError) { URI.parse('http://a_b/') } # 8 - # reporte by m_seki + # reported by m_seki uri = URI.parse('file:///foo/bar.txt') assert_kind_of(URI::Generic, url) uri = URI.parse('file:/foo/bar.txt') assert_kind_of(URI::Generic, url) + + # 9 + # [ruby-dev:25667] + url = URI.parse('ftp://:pass@localhost/') + assert_equal('', url.user) + assert_equal('pass', url.password) + assert_equal(':pass', url.userinfo) + url = URI.parse('ftp://user@localhost/') + assert_equal('user', url.user) + assert_equal(nil, url.password) + assert_equal('user', url.userinfo) + url = URI.parse('ftp://localhost/') + assert_equal(nil, url.user) + assert_equal(nil, url.password) + assert_equal(nil, url.userinfo) end def test_merge |