瀏覽代碼

improve validation on text indexing, for search (#294)

Markos Gogoulos 3 年之前
父節點
當前提交
f974d78270
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      files/models.py

+ 4 - 2
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}'