aboutsummaryrefslogtreecommitdiffstats
path: root/modules/util/util.go
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-02-01 13:59:25 +0100
committerGitHub <noreply@github.com>2022-02-01 20:59:25 +0800
commitbb5f859ec0f853383b85cb16b189fbacf7397551 (patch)
tree6ee234ba1f3c70bb6b55f0d7cc831ecf7f668110 /modules/util/util.go
parent7f2530e004c9908f9ee18b4060c8d4837a72f93b (diff)
downloadgitea-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.go11
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)
+}