From 57454bffa0a6cdf87769d3459fa96ae27b81886d Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Tue, 11 Dec 2018 14:02:15 +0100 Subject: [PATCH] forum: workaround size error while building index, handle malformed utf8 --- core/search_indexes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/search_indexes.py b/core/search_indexes.py index 75dc262d..86401eed 100644 --- a/core/search_indexes.py +++ b/core/search_indexes.py @@ -99,7 +99,9 @@ class BigCharFieldIndex(indexes.CharField): """ 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):