From e197dcb3554aa4a59cfea9712e96cb7d0bc01734 Mon Sep 17 00:00:00 2001 From: akira Date: Tue, 23 Dec 2003 05:17:00 +0000 Subject: * lib/uri/generic.rb (URI::Generic::check_userinfo, URI::Generic::check_user, URI::Generic::check_password): tests conflicts/depends with other components closely. * test/uri/test_generic.rb (TestGeneric::test_set_component): added tets. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/uri/generic.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/uri/generic.rb') diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index a96810146..c1d0d63ca 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -265,23 +265,22 @@ Object # methods for userinfo # def check_userinfo(user, password = nil) - if (user || password) && - (@registry || @opaque) - raise InvalidURIError, - "can not set userinfo with registry or opaque" - end - if !password user, password = split_userinfo(user) end check_user(user) - check_password(password) + check_password(password, user) return true end private :check_userinfo def check_user(v) + if @registry || @opaque + raise InvalidURIError, + "can not set user with registry or opaque" + end + return v unless v if USERINFO !~ v @@ -293,10 +292,14 @@ Object end private :check_user - def check_password(v) + def check_password(v, user = @user) + if @registry || @opaque + raise InvalidURIError, + "can not set password with registry or opaque" + end return v unless v - if !@password + if !user raise InvalidURIError, "password component depends user component" end -- cgit