summaryrefslogtreecommitdiff
path: root/lib/uri
diff options
context:
space:
mode:
authorakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-23 05:17:00 +0000
committerakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-23 05:17:00 +0000
commit4bb0fd231e66e61c76396b47b2b7eb8d72cec1c7 (patch)
treee7e96da0e6fa28dfbab76113f502ea81d574363e /lib/uri
parent53ebcbf733d3eaeca1fb7a49d5621054917951c7 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@5256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri')
-rw-r--r--lib/uri/generic.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index a968101468..c1d0d63cae 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