MM-46871: Add remining search parameters to be escaped (#20963)
The first try wasn't exhaustive. I was planning to use
1f933263e7/store/sqlstore/post_store.go (L1738-L1748) for this
but it also contained `@` which we don't want.
In the end, I just used a separate slice for all
the characters to be escaped.
https://mattermost.atlassian.net/browse/MM-46871
```release-note
NONE
```
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
8b328386c5
Коммит
8797bfcde7
@@ -1503,8 +1503,11 @@ func generateSearchQuery(query sq.SelectBuilder, terms []string, fields []string
|
||||
var dbSpecificTerm string
|
||||
|
||||
if isPostgreSQL {
|
||||
// Escaping the : in case of a Postgres search.
|
||||
term = strings.ReplaceAll(term, ":", "\\:")
|
||||
// Refer to https://www.postgresql.org/docs/current/functions-textsearch.html for the list of operators.
|
||||
for _, c := range []string{":", "(", ")", "<", "!", "|"} {
|
||||
// Escaping the special chars in case of a Postgres search.
|
||||
term = strings.ReplaceAll(term, c, "\\"+c)
|
||||
}
|
||||
}
|
||||
|
||||
for _, field := range fields {
|
||||
|
||||
Ссылка в новой задаче
Block a user