forum: workaround size error while building index, handle malformed utf8

This commit is contained in:
Antoine Bartuccio 2018-12-11 14:02:15 +01:00 committed by Skia
parent 641d564ec6
commit 57454bffa0

View File

@ -99,7 +99,9 @@ class BigCharFieldIndex(indexes.CharField):
""" """
def prepare(self, term): def prepare(self, term):
return super(BigCharFieldIndex, self).prepare(term)[:240] return bytes(super(BigCharFieldIndex, self).prepare(term), "utf-8")[
:245
].decode("utf-8", errors="ignore")
class ForumMessageIndex(indexes.SearchIndex, indexes.Indexable): class ForumMessageIndex(indexes.SearchIndex, indexes.Indexable):