qtprotobufgen: Escape json_name in the generated field metadata


The JSON name of every field is written into a string literal and into
comments of the generated message metadata. Unlike field and message
names, json_name is not limited to identifier characters: the
[json_name = "..."] option takes any string literal, and protoc only
rejects an embedded NUL. A quote, a newline or "*/" in it ended the
literal or comment, and the rest of the name was compiled as C++. A
backslash sequence silently decoded into other bytes than the ones the
array size and offsets were computed from, giving wrong JSON keys.

Write the name as a C string literal, with control and non-ASCII bytes
as fixed-width octal; a \x escape would swallow following hex digits.
The decoded literal then matches the raw bytes the size and offsets are
based on. In the comments, also neutralize "*/" and "/*".

A name starting with an octal digit merged into the \0 that separates
it from the previous name, so such a name now starts a new literal.

Generated code for names without such characters is unchanged.

[ChangeLog][QtProtobuf][qtprotobufgen] A json_name containing quotes,
backslashes, newlines, comment delimiters or a leading digit now
generates correct code. Such names previously broke the generated
source or produced wrong JSON keys.

Fixes: QTBUG-151087
Task-number: QTBUG-151088
Pick-to: 6.12 6.11 6.8
Change-Id: Ie9479c76c19ad4b9f510825a14de96afcd6484ba
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
commit6dbc0215391a724e340d86f3ed898ef22629e866
parent02b524d8e88232013409f530277c490e8de69ba7
authorDennis Oberst <dennis.oberst@qt.io>
committerDennis Oberst <dennis.oberst@qt.io>
commit timeWed, 14 Oct 2026 09:24:25 +0000