Whitespace is not trimmed from the end of query strings (#1263)

* fixed whitespace not trimmed query string
* fixed whitespace trimming on backend
* added query trim tests and fixed double space
This commit is contained in:
julien0221
2021-04-13 01:32:52 +01:00
committed by GitHub
parent f5dc654f6b
commit 6a4421f8e1
5 changed files with 67 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import (
"database/sql"
"fmt"
"math/rand"
"regexp"
"strconv"
"strings"
@@ -116,10 +117,12 @@ func getSearchBinding(columns []string, q string, not bool) (string, []interface
notStr = " NOT"
binaryType = " AND "
}
queryWords := strings.Split(q, " ")
q = strings.TrimSpace(q)
trimmedQuery := strings.Trim(q, "\"")
if trimmedQuery == q {
q = regexp.MustCompile(`\s+`).ReplaceAllString(q, " ")
queryWords := strings.Split(q, " ")
// Search for any word
for _, word := range queryWords {
for _, column := range columns {