summaryrefslogtreecommitdiffstats
path: root/lib/uri/generic.rb
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
commite197dcb3554aa4a59cfea9712e96cb7d0bc01734 (patch)
treee7e96da0e6fa28dfbab76113f502ea81d574363e /lib/uri/generic.rb
parenta034a09b2216e4b96c50fcce75e5a7d23eb868a7 (diff)
downloadruby-e197dcb3554aa4a59cfea9712e96cb7d0bc01734.tar.gz
ruby-e197dcb3554aa4a59cfea9712e96cb7d0bc01734.tar.xz
ruby-e197dcb3554aa4a59cfea9712e96cb7d0bc01734.zip
* 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
Diffstat (limited to 'lib/uri/generic.rb')
-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 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