fix(slogutil): quote values with parentheses in them (#10229)

Avoids an obvious parsing ambiguity in log lines.
This commit is contained in:
Jakob Borg
2025-08-07 09:47:50 +00:00
committed by GitHub
parent 836045ee87
commit 431da839cf
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ func appendAttr(sb *strings.Builder, prefix string, a slog.Attr, attrCount *int)
sb.WriteString(a.Key)
sb.WriteRune('=')
v := a.Value.Resolve().String()
if strings.ContainsAny(v, ` "`) {
if strings.ContainsAny(v, ` "()`) {
v = strconv.Quote(v)
}
sb.WriteString(v)