photoprism/pkg/clean/header.go
Michael Mayer 239708f00f Config: Add options to configure CORS origin, headers and methods #3931
Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-16 12:14:06 +01:00

18 lines
314 B
Go

package clean
// Header sanitizes a string for use in request or response headers.
func Header(s string) string {
if s == "" || len(s) > MaxLength {
return ""
}
result := make([]rune, 0, len(s))
for _, r := range s {
if r > 31 && r < 127 {
result = append(result, r)
}
}
return string(result)
}