0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-30 01:46:24 +01:00

moving tsvector query sanitation to

This commit is contained in:
Hammy Goonan 2019-01-20 14:38:16 +11:00 committed by Bertrand Bordage
parent be02bcef3c
commit 8fa7a41011
2 changed files with 3 additions and 4 deletions

View File

@ -228,9 +228,7 @@ class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
return self.get_search_field(sub_field_name, field.fields)
def prepare_word(self, word):
# remove backslash from string to prevent syntax error in tsquery
stripped_word = word.replace("\\", "")
return unidecode(stripped_word)
return unidecode(word)
def build_tsquery_content(self, query, group=False):
if isinstance(query, PlainText):

View File

@ -18,7 +18,8 @@ class RawSearchQuery(SearchQuery):
super().__init__(*args, **kwargs)
def as_sql(self, compiler, connection):
params = [v.replace("'", "''") for v in self.value]
# escape apostrophe and backslash
params = [v.replace("'", "''").replace("\\", "\\\\") for v in self.value]
if self.config:
config_sql, config_params = compiler.compile(self.config)
template = "to_tsquery(%s::regconfig, '%s')" % (config_sql, self.format)