mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-08 02:01:23 +00:00
Fix: Handle incoming labels with invalid UTF-8
It's possible that incoming labels will contain invalid UTF-8 characters. This results in a panic. This fix sanitizes the label's string to ensure only valid UTF-8 characters are included, by replacing invalid characters with � (REPLACEMENT CHARACTER) Signed-off-by: Cooper Worobetz <cooper@worobetz.ca>
This commit is contained in:
parent
51006aba2f
commit
0df86c2384
@ -159,7 +159,7 @@ func dbToString(t interface{}) (string, bool) {
|
||||
// Try and convert to string
|
||||
return string(v), true
|
||||
case string:
|
||||
return v, true
|
||||
return strings.ToValidUTF8(v, "<22>"), true
|
||||
case bool:
|
||||
if v {
|
||||
return "true", true
|
||||
|
Loading…
Reference in New Issue
Block a user