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

@@ -20,6 +20,10 @@ import (
"github.com/stashapp/stash/pkg/utils"
)
const (
spacedSceneTitle = "zzz yyy xxx"
)
const (
sceneIdxWithMovie = iota
sceneIdxWithGallery
@@ -33,6 +37,7 @@ const (
sceneIdxWithMarker
sceneIdxWithPerformerTag
sceneIdxWithPerformerTwoTags
sceneIdxWithSpacedName
// new indexes above
lastSceneIdx
@@ -452,6 +457,15 @@ func getSceneNullStringValue(index int, field string) sql.NullString {
return getPrefixedNullStringValue("scene", index, field)
}
func getSceneTitle(index int) string {
switch index {
case sceneIdxWithSpacedName:
return spacedSceneTitle
default:
return getSceneStringValue(index, titleField)
}
}
func getRating(index int) sql.NullInt64 {
rating := index % 6
return sql.NullInt64{Int64: int64(rating), Valid: rating > 0}
@@ -493,7 +507,7 @@ func createScenes(sqb models.SceneReaderWriter, n int) error {
for i := 0; i < n; i++ {
scene := models.Scene{
Path: getSceneStringValue(i, pathField),
Title: sql.NullString{String: getSceneStringValue(i, titleField), Valid: true},
Title: sql.NullString{String: getSceneTitle(i), Valid: true},
Checksum: sql.NullString{String: getSceneStringValue(i, checksumField), Valid: true},
Details: sql.NullString{String: getSceneStringValue(i, "Details"), Valid: true},
URL: getSceneNullStringValue(i, urlField),