Skip to content

Commit

Permalink
[#1117] user_update don't crash on non-string name
Browse files Browse the repository at this point in the history
Don't crash if the user tries to update their user name to a value that
is not a string (which they can do, using the API)
  • Loading branch information
Sean Hammond committed Jul 17, 2013
1 parent 3491cd6 commit bc3baa9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ckan/logic/validators.py
Expand Up @@ -276,6 +276,9 @@ def extras_unicode_convert(extras, context):

name_match = re.compile('[a-z0-9_\-]*$')
def name_validator(val, context):
if not isinstance(val, basestring):
raise Invalid(_('Names must be strings'))

# check basic textual rules
if val in ['new', 'edit', 'search']:
raise Invalid(_('That name cannot be used'))
Expand Down Expand Up @@ -478,6 +481,9 @@ def user_name_validator(key, data, errors, context):
session = context["session"]
user = context.get("user_obj")

if not isinstance(data[key], basestring):
raise Invalid(_('User names must be strings'))

query = session.query(model.User.name).filter_by(name=data[key])
if user:
user_id = user.id
Expand Down

0 comments on commit bc3baa9

Please sign in to comment.