1
0
Fork 0
forked from forgejo/forgejo

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
This commit is contained in:
Gusted 2022-02-01 13:59:25 +01:00 committed by GitHub
parent 7f2530e004
commit bb5f859ec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 1 deletions

View file

@ -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)
}