43f7b869
wire: reject invalid UTF-8 in proto3 string fields
Per the proto3 spec, a string field's bytes must form valid UTF-8. decode_string was aliased to decode_len, so any byte sequence was accepted and round-tripped. Adds a pure-Lua RFC 3629 validator — is_valid_utf8 — and routes M.decode_string through it. The bytes type keeps the raw decode_len path so binary payloads still pass. The validator covers stray continuation bytes, truncated sequences, overlong encodings, UTF-16 surrogates (U+D800..U+DFFF), and code points above U+10FFFF. Codec, lazy, dynamic, and the generated inline code all consume the same M.decode_string, so singular / repeated / oneof / map-key / map-value string fields are all covered. Drops 5 entries from test/conformance/known_failures.txt (RejectInvalidUtf8.String.*) and adds 7 regression tests covering each invalid form plus a positive multi-byte string round-trip and a bytes-field control.
Eugene Blikh <bigbes@gmail.com> — 2026-05-15 21:43:43 UTC
Commit 43f7b869d1b39ad485f37df3e554a5f485795378 —
view raw patch
Parent(s):
2ed0f4b5
| File | Status | + | − |
|---|---|---|---|
runtime/pb/wire.lua
|
M | +56 | -2 |
test/conformance/known_failures.txt
|
M | -5 | |
test/conformance_test.lua
|
M | +54 |