Skip to content

Commit 658a3ac

Browse files
fix: escape quotes in quoted strings, handle empty strings per spec
1 parent 312fd43 commit 658a3ac

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/gcf/generic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ def _format_value(value: Any) -> str:
140140
if isinstance(value, (int, float)):
141141
return str(value)
142142
s = str(value)
143-
if "|" in s or "\n" in s:
144-
return f'"{s}"'
143+
if "|" in s or "\n" in s or s == "":
144+
escaped = s.replace("\\", "\\\\").replace('"', '\\"')
145+
return f'"{escaped}"'
145146
return s
146147

147148

0 commit comments

Comments
 (0)