Skip to content

Commit 39224f9

Browse files
fix: reject missing tool field, escape newlines in quoted strings (conformance)
1 parent 41adc88 commit 39224f9

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v0.1.3 (2026-06-04)
4+
5+
- Docs: update README for PyPI discoverability (gcformat.com, proxy, vs-toon links)
6+
- Fix: decoder rejects headers missing required `tool` field (conformance)
7+
- Fix: escape newlines as `\n` in quoted strings in `encode_generic`
8+
39
## v0.1.2 (2026-06-04)
410

511
- Fix: escape `"` inside quoted strings in `encode_generic`

src/gcf/decode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def decode(input_text: str) -> Payload:
3434
raise DecodeError(f"invalid header, expected 'GCF ...' got {header!r}")
3535
_parse_header(header[4:], p)
3636

37+
if not p.tool:
38+
raise DecodeError("header missing required 'tool' field")
39+
3740
# Parse body: symbols and edges.
3841
symbols: list[Symbol] = []
3942
sym_by_id: dict[int, Symbol] = {}

src/gcf/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _format_value(value: Any) -> str:
142142
return str(value)
143143
s = str(value)
144144
if "|" in s or "\n" in s or s == "":
145-
escaped = s.replace("\\", "\\\\").replace('"', '\\"')
145+
escaped = s.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n")
146146
return f'"{escaped}"'
147147
return s
148148

0 commit comments

Comments
 (0)