diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-02-01 13:59:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-01 20:59:25 +0800 |
commit | bb5f859ec0f853383b85cb16b189fbacf7397551 (patch) | |
tree | 6ee234ba1f3c70bb6b55f0d7cc831ecf7f668110 /modules/util/util.go | |
parent | 7f2530e004c9908f9ee18b4060c8d4837a72f93b (diff) | |
download | gitea-bb5f859ec0f853383b85cb16b189fbacf7397551.tar.gz gitea-bb5f859ec0f853383b85cb16b189fbacf7397551.zip |
Fix non-ASCII search on database (#18437)
Use `ToASCIIUpper` for SQLite database on issues search, this because `UPPER(x)` on SQLite only transforms ASCII letters. Resolves #18429
Diffstat (limited to 'modules/util/util.go')
-rw-r--r-- | modules/util/util.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/util/util.go b/modules/util/util.go index 90d0eca15c..af6581f7cd 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -170,3 +170,14 @@ func CryptoRandomBytes(length int64) ([]byte, error) { _, err := rand.Read(buf) return buf, err } + +// ToUpperASCII returns s with all ASCII letters mapped to their upper case. +func ToUpperASCII(s string) string { + b := []byte(s) + for i, c := range b { + if 'a' <= c && c <= 'z' { + b[i] -= 'a' - 'A' + } + } + return string(b) +} |