Catch TypeErrors from bleach

This commit is contained in:
James Polley 2017-09-30 22:50:13 +10:00
parent e51ad76384
commit 287d412ccf

View file

@ -572,7 +572,10 @@ def attendee(request, form, user_id=None):
if isinstance(field, models.ManyToManyField):
value = ", ".join(str(i) for i in value.all())
elif isinstance(field, CharField):
try:
value = bleach.clean(value)
except TypeError:
value = "Bad value for %s" % field.name
profile_data.append((field.verbose_name, value))
@ -813,7 +816,7 @@ def attendee_data(request, form, user_id=None):
return None
else:
def display_field(value):
return bleach.clean(value)
return bleach.clean(str(value))
status_count = lambda status: Case(When( # noqa
attendee__user__cart__status=status,
@ -860,7 +863,10 @@ def attendee_data(request, form, user_id=None):
if isinstance(field_type, models.ManyToManyField):
return [str(i) for i in attr.all()] or ""
else:
try:
return bleach.clean(attr)
except TypeError:
return "Bad value found for %s" % attr
headings = ["User ID", "Name", "Email", "Product", "Item Status"]
headings.extend(field_names)