prefect server in zig

Validate percent digits without changing tolerant form decoding #35

Open zzstoatzz.io
Open opened by zzstoatzz.io

At current default-branch commit b57cddeeb0ae2b67a087bafd8fff521301f9d578, urlDecode in src/utilities/encoding.zig:22 uses std.fmt.parseInt(u8, pair, 16) for percent pairs.

On Zig 0.17.0, %+A becomes newline and %-0 becomes NUL. These are malformed percent escapes, not hexadecimal byte encodings. No downstream exploit is claimed.

The utility deliberately tolerates malformed percent escapes and maps raw + to space. Fix per-digit validation while retaining that behavior: handle signed pairs through the existing malformed-input path, keep %2B as literal plus, and decode once. In particular, the existing fallback processes following characters normally, so raw plus handling still applies after an invalid %.

Zat v0.7.0-alpha.10 has a strict URI decoder, but changing this utility to strict rejection or literal-plus behavior would be a separate contract change. Review actual callers before choosing shared adoption; a local charToDigit fix may be sufficient.

Acceptance: add signed/nonhex/truncated escapes and plus/decode-once regressions alongside existing allocation-failure tests; run replayable fuzz/property checks against the tolerant form contract, adversarial review, and focused before/after performance tests before shipping.

Background: shared decoder review and downstream audit.

Related: Zat form-decoding ownership/API follow-up.

Sign up or Sign in to add to the discussion.