239708f00f
Signed-off-by: Michael Mayer <michael@photoprism.app>
18 lines
314 B
Go
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)
|
|
}
|