Skip to content

api_dump: Escape strings in JSON output - #3

Merged
wpaul-samsung merged 1 commit into
mainfrom
escape-strings
Oct 19, 2026
Merged

wpaul-samsung merged 1 commit into
mainfrom
escape-strings

Conversation

@wpaul-samsung

Copy link
Copy Markdown

dump_char wrote string values into the JSON dump as-is, wrapped in quotes. A string containing a line break, quote, backslash or other control character made the .apidump file invalid JSON, and readers stopped parsing at that point, losing every frame after it. Vulkan Samples "subpasses" triggers this: it names a render pass "RP with 2 subpasses:" followed by line breaks.

Add dump_json_string_w, which escapes '"', '\' and all control characters as JSON requires (\n, \r, \t, \b, \f, and \u00XX for the rest), and use it in dump_char's JSON path. Text that needs no escaping is still written in one piece through ApiDumpFastWriter.

Every string the layer dumps goes through dump_char: all 58 generated char*, char[N] and char* array fields and parameters, including object names, debug labels, instance info, layer and extension names, and device and driver properties. The generator does the same for every char type, so the fix holds when the code is regenerated. Other JSON values (function names, type names, numbers, flags) are fixed text or numbers. Text and HTML output are unchanged.

[Co-Developed using AI] Claude-opus-5.5

dump_char wrote string values into the JSON dump as-is, wrapped in
quotes. A string containing a line break, quote, backslash or other
control character made the .apidump file invalid JSON, and readers
stopped parsing at that point, losing every frame after it. Vulkan
Samples "subpasses" triggers this: it names a render pass
"RP with 2 subpasses:" followed by line breaks.

Add dump_json_string_w, which escapes '"', '\\' and all control
characters as JSON requires (\n, \r, \t, \b, \f, and \u00XX for the
rest), and use it in dump_char's JSON path. Text that needs no
escaping is still written in one piece through ApiDumpFastWriter.

Every string the layer dumps goes through dump_char: all 58 generated
char*, char[N] and char* array fields and parameters, including
object names, debug labels, instance info, layer and extension names,
and device and driver properties. The generator does the same for
every char type, so the fix holds when the code is regenerated. Other
JSON values (function names, type names, numbers, flags) are fixed
text or numbers. Text and HTML output are unchanged.

[Co-Developed using AI] Claude-opus-5.5
@wpaul-samsung
wpaul-samsung merged commit acf364b into main Oct 19, 2026
24 checks passed
@wpaul-samsung
wpaul-samsung deleted the escape-strings branch October 19, 2026 21:31
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