Allow proper ruby types for evasion configuration

At some point in the distant past, the datastore was all strings and the
various option types got parsed out in the appropriate places. Then, in
the somewhat more recent past, the options started getting converted to
regular ruby types (such as TrueClass for a BOOL options, etc) earlier
in their life.  Apparently, that change broke boolean http evasions.
This commit fixes them by ensuring that +true+ is just as acceptable as
"true".

Fixes #6198, thanks Ashish for the report
This commit is contained in:
James Lee 2012-01-06 20:05:29 -07:00
parent 6ceb2f04a3
commit 7ea5f87960
1 changed files with 7 additions and 1 deletions

View File

@ -99,16 +99,22 @@ class Client
#
def set_config(opts = {})
opts.each_pair do |var,val|
# Default type is string
typ = self.config_types[var] || 'string'
# These are enum types
if(typ.class.to_s == 'Array')
if not typ.include?(val)
raise RuntimeError, "The specified value for #{var} is not one of the valid choices"
end
end
# The caller should have converted these to proper ruby types, but
# take care of the case where they didn't before setting the
# config.
if(typ == 'bool')
val = (val =~ /^(t|y|1)$/i ? true : false)
val = (val =~ /^(t|y|1)$/i ? true : false || val === true)
end
if(typ == 'integer')