mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user