Skip to content

Commit ab35c38

Browse files
phenomenon0claude
andcommitted
fix: align security limits across all languages, correct license declarations
- Tighten JS parse.ts limits to match all other impls: depth 256→128, collection 10M→1M, string 500MB→10MB - Raise Python parse.py depth from 100→128 (was 28 levels stricter than every other implementation, causing cross-language desync) - Update depth overflow tests to use 129 (exceeds new canonical limit) - Fix Rust Cargo.toml and C README license: MIT→Apache-2.0 (project is Apache-2.0) - Fix bare except: in demo-server.py (swallowed KeyboardInterrupt) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e05e34b commit ab35c38

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

c/glyph-codec/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ char *glyph = glyph_canonicalize_loose(v);
160160

161161
## License
162162

163-
MIT
163+
Apache-2.0

demo-server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def do_GET(self):
265265

266266
try:
267267
return super().do_GET()
268-
except:
268+
except Exception:
269269
self.send_response(404)
270270
self.end_headers()
271271

js/src/parse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export function parsePacked(input: string, schema: Schema): GValue {
2121
return parser.parse();
2222
}
2323

24-
const MAX_PARSE_DEPTH = 256;
25-
const MAX_COLLECTION_LEN = 10_000_000; // 10M elements
26-
const MAX_STRING_LEN = 500_000_000; // 500MB
24+
const MAX_PARSE_DEPTH = 128; // aligned with loose.ts, C, Python
25+
const MAX_COLLECTION_LEN = 1_000_000; // 1M elements (aligned across all impls)
26+
const MAX_STRING_LEN = 10 * 1024 * 1024; // 10MB (aligned across all impls)
2727

2828
class PackedParser {
2929
private input: string;

py/glyph/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Token:
4949
pos: int
5050

5151

52-
DEFAULT_MAX_DEPTH = 100
52+
DEFAULT_MAX_DEPTH = 128 # aligned with Go, JS, C, Rust
5353
MAX_COLLECTION_LEN = 1_000_000 # 1M elements
5454
MAX_STRING_LEN = 10 * 1024 * 1024 # 10MB
5555

py/tests/test_glyph.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def test_rejects_non_finite_and_overflow_float_literals(self, text):
289289
parse(text)
290290

291291
def test_limits_nesting_depth(self):
292-
deeply_nested = "[" * 101 + "0" + "]" * 101
292+
deeply_nested = "[" * 129 + "0" + "]" * 129
293293
with pytest.raises(ValueError, match="maximum nesting depth"):
294294
parse(deeply_nested)
295295

@@ -613,17 +613,17 @@ def test_nesting_depth_map(self):
613613
# Should work at depth 50
614614
v = parse(text)
615615
# Now try exceeding
616-
deep = "{a=" * 101 + "1" + "}" * 101
616+
deep = "{a=" * 129 + "1" + "}" * 129
617617
with pytest.raises(ValueError, match="maximum nesting depth"):
618618
parse(deep)
619619

620620
def test_nesting_depth_struct(self):
621-
deep = "S{x=" * 101 + "1" + "}" * 101
621+
deep = "S{x=" * 129 + "1" + "}" * 129
622622
with pytest.raises(ValueError, match="maximum nesting depth"):
623623
parse(deep)
624624

625625
def test_nesting_depth_sum(self):
626-
deep = "T(" * 101 + "1" + ")" * 101
626+
deep = "T(" * 129 + "1" + ")" * 129
627627
with pytest.raises(ValueError, match="maximum nesting depth"):
628628
parse(deep)
629629

rust/glyph-codec/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "glyph-rs"
33
version = "1.0.0"
44
edition = "2021"
55
description = "GLYPH codec - token-efficient serialization for AI agents"
6-
license = "MIT"
6+
license = "Apache-2.0"
77
repository = "https://github.com/Neumenon/glyph"
88
keywords = ["serialization", "codec", "llm", "ai", "json"]
99
categories = ["encoding", "parser-implementations"]

0 commit comments

Comments
 (0)