summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/uri/generic.rb9
-rw-r--r--test/uri/test_generic.rb17
3 files changed, 22 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 437cf664c9..759ac04679 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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