From f974d7827093e6f032f5ead181e34462c9d83f59 Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Fri, 1 Oct 2021 17:49:41 +0300 Subject: [PATCH] improve validation on text indexing, for search (#294) --- files/models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files/models.py b/files/models.py index e406d24..d6a4174 100644 --- a/files/models.py +++ b/files/models.py @@ -395,11 +395,11 @@ class Media(models.Model): b_tags = " ".join([tag.title.replace("-", " ") for tag in self.tags.all()]) items = [ - helpers.clean_query(self.title), + self.title, self.user.username, self.user.email, self.user.name, - helpers.clean_query(self.description), + self.description, a_tags, b_tags, ] @@ -407,6 +407,8 @@ class Media(models.Model): text = " ".join(items) text = " ".join([token for token in text.lower().split(" ") if token not in STOP_WORDS]) + text = helpers.clean_query(text) + sql_code = """ UPDATE {db_table} SET search = to_tsvector( '{config}', '{text}'