[MM-18036] Sanitize sql LIKE terms on search endpoints (#12044)
* Sanitize sql LIKE terms on search endpoints * Add search term sanitization in additional places
Этот коммит содержится в:
коммит произвёл
Daniel Schalla
родитель
8b969426f0
Коммит
814c234443
@@ -2,6 +2,8 @@ package sqlstore
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMapStringsToQueryParams(t *testing.T) {
|
||||
@@ -30,3 +32,29 @@ func TestMapStringsToQueryParams(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestSanitizeSearchTerm(t *testing.T) {
|
||||
term := "test"
|
||||
result := sanitizeSearchTerm(term, "\\")
|
||||
require.Equal(t, result, term)
|
||||
|
||||
term = "%%%"
|
||||
expected := "\\%\\%\\%"
|
||||
result = sanitizeSearchTerm(term, "\\")
|
||||
require.Equal(t, result, expected)
|
||||
|
||||
term = "%\\%\\%"
|
||||
expected = "\\%\\%\\%"
|
||||
result = sanitizeSearchTerm(term, "\\")
|
||||
require.Equal(t, result, expected)
|
||||
|
||||
term = "%_test_%"
|
||||
expected = "\\%\\_test\\_\\%"
|
||||
result = sanitizeSearchTerm(term, "\\")
|
||||
require.Equal(t, result, expected)
|
||||
|
||||
term = "**test_%"
|
||||
expected = "test*_*%"
|
||||
result = sanitizeSearchTerm(term, "*")
|
||||
require.Equal(t, result, expected)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user