Skip to content

Escape each control character of a tool word and check float ints - #65

Merged
beetlebugorg merged 1 commit into
mainfrom
mcp-args
Nov 28, 2026
Merged

beetlebugorg merged 1 commit into
mainfrom
mcp-args

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

Part of #15.

word() of src/app/mcp.zig escaped \n, \r, and \t only. Tcl splits words at \v and \f too, and a NUL ends a C string. Each other control character (0x00 to 0x1f and 0x7f) now goes into the word as \\u00XX, so a tool argument stays one Tcl word.

argInt() converted any JSON float with @intFromFloat(@round(f)), which is illegal behavior for 1e300, an infinity, or NaN (undefined in ReleaseFast). A float that is not finite or is beyond 2^53 is now error.BadArgument.

Tests: a VT, an FF, and a NUL in a type argument stay in one word; 2.6 gives 3; 1e300 and NaN give BadArgument. Local: zig fmt --check and zig ast-check pass. The tests are not run locally, since builds are paused on this host; QA runs them.

@beetlebugorg beetlebugorg added this to the Sandbox milestone Nov 27, 2026
word() writes NUL, VT, FF, and each other control character as \u00XX,
so a tool argument stays one Tcl word. argInt() refuses a float that is
not finite or is out of the exact integer range of f64.
@beetlebugorg
beetlebugorg merged commit 15f69e8 into main Nov 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant