mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-05 18:12:46 +00:00
a156188b3e
* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package http2
|
|
|
|
import "strings"
|
|
|
|
// The HTTP protocols are defined in terms of ASCII, not Unicode. This file
|
|
// contains helper functions which may use Unicode-aware functions which would
|
|
// otherwise be unsafe and could introduce vulnerabilities if used improperly.
|
|
|
|
// asciiEqualFold is strings.EqualFold, ASCII only. It reports whether s and t
|
|
// are equal, ASCII-case-insensitively.
|
|
func asciiEqualFold(s, t string) bool {
|
|
if len(s) != len(t) {
|
|
return false
|
|
}
|
|
for i := 0; i < len(s); i++ {
|
|
if lower(s[i]) != lower(t[i]) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// lower returns the ASCII lowercase version of b.
|
|
func lower(b byte) byte {
|
|
if 'A' <= b && b <= 'Z' {
|
|
return b + ('a' - 'A')
|
|
}
|
|
return b
|
|
}
|
|
|
|
// isASCIIPrint returns whether s is ASCII and printable according to
|
|
// https://tools.ietf.org/html/rfc20#section-4.2.
|
|
func isASCIIPrint(s string) bool {
|
|
for i := 0; i < len(s); i++ {
|
|
if s[i] < ' ' || s[i] > '~' {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// asciiToLower returns the lowercase version of s if s is ASCII and printable,
|
|
// and whether or not it was.
|
|
func asciiToLower(s string) (lower string, ok bool) {
|
|
if !isASCIIPrint(s) {
|
|
return "", false
|
|
}
|
|
return strings.ToLower(s), true
|
|
}
|