...
1 package va
2
3 import (
4 "strings"
5 "unicode/utf8"
6
7 "github.com/letsencrypt/boulder/probs"
8 )
9
10
11
12 func replaceInvalidUTF8(input []byte) string {
13 if utf8.Valid(input) {
14 return string(input)
15 }
16
17 var b strings.Builder
18
19
20
21 for _, v := range string(input) {
22 b.WriteRune(v)
23 }
24 return b.String()
25 }
26
27
28
29 func filterProblemDetails(prob *probs.ProblemDetails) *probs.ProblemDetails {
30 if prob == nil {
31 return nil
32 }
33 return &probs.ProblemDetails{
34 Type: probs.ProblemType(replaceInvalidUTF8([]byte(prob.Type))),
35 Detail: replaceInvalidUTF8([]byte(prob.Detail)),
36 HTTPStatus: prob.HTTPStatus,
37 }
38 }
39
View as plain text