don't fail on invalid arrays

This commit is contained in:
j 2021-05-19 16:02:18 +01:00
parent 54362e8b41
commit c17cc6d5cf

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import json
import logging
import os
import re
import shutil
@ -42,6 +43,7 @@ from user.utils import update_groups
from user.models import Group
import archive.models
logger = logging.getLogger(__name__)
User = get_user_model()
@ -855,7 +857,7 @@ class Item(models.Model):
values = list(set(values))
else:
values = self.get(key, '')
if isinstance(values, list):
if values and isinstance(values, list) and isinstance(values[0], str):
save(key, '\n'.join(values))
else:
save(key, values)
@ -1099,7 +1101,11 @@ class Item(models.Model):
_current_values.append(value[0])
current_values = _current_values
current_values = list(set(current_values))
try:
current_values = list(set(current_values))
except:
logger.error('invalid facet data for %s: %s', key, current_values)
current_values = []
current_values = [ox.decode_html(ox.strip_tags(v)) for v in current_values]
current_values = [unicodedata.normalize('NFKD', v) for v in current_values]
self.update_facet_values(key, current_values)