SanitizeLogOutput replaces invalid UTF-8 and NUL characters in log output. Invalid UTF-8 cannot be transported in protobuf string fields, and PostgreSQL rejects NUL bytes in text columns.
(s string)
| 6 | // Invalid UTF-8 cannot be transported in protobuf string fields, and PostgreSQL |
| 7 | // rejects NUL bytes in text columns. |
| 8 | func SanitizeLogOutput(s string) string { |
| 9 | s = strings.ToValidUTF8(s, "❌") |
| 10 | return strings.ReplaceAll(s, "\x00", "❌") |
| 11 | } |
no outgoing calls