From 7d665ab68a88b01431c7b51153507c9a98fd6333 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 15 Feb 2007 00:11:17 +0000 Subject: Stringify password when creating botuser. Useful when e.g. conf.yaml contains a master password which is numeric and unquoted --- lib/rbot/botuser.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index 52b83151..c0041d7f 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -263,18 +263,19 @@ module Irc # This method sets the password if the proposed new password # is valid def password=(pwd=nil) - if pwd + pass = pwd.to_s + if pass.empty? + reset_password + else begin - raise InvalidPassword, "#{pwd} contains invalid characters" if pwd !~ /^[A-Za-z0-9]+$/ - raise InvalidPassword, "#{pwd} too short" if pwd.length < 4 - @password = pwd + raise InvalidPassword, "#{pass} contains invalid characters" if pass !~ /^[A-Za-z0-9]+$/ + raise InvalidPassword, "#{pass} too short" if pass.length < 4 + @password = pass rescue InvalidPassword => e raise e rescue => e - raise InvalidPassword, "Exception #{e.inspect} while checking #{pwd}" + raise InvalidPassword, "Exception #{e.inspect} while checking #{pass.inspect} (#{pwd.inspect})" end - else - reset_password end end -- cgit v1.2.3