8000 Limit how deep macro XML nests by dominion525 · Pull Request #104 · dominion525/jetdb · GitHub
[go: up one dir, main page]

Skip to content

Limit how deep macro XML nests - #104

Merged
dominion525 merged 2 commits into
mainfrom
fix/macro-xml-depth
Oct 20, 2026
Merged

dominion525 merged 2 commits into
mainfrom
fix/macro-xml-depth

Conversation

@dominion525
Copy link
Copy Markdown
Owner

Summary

  • Building the statements of macro XML, copying and dropping its tree, and making its JavaScript objects in Wasm recur on each level of nesting. A file could nest them deep enough to use up the stack: in Wasm, with its 1 MB stack, about 2,000 levels of statement groups, some 230 KB of XML, trapped, and the CLI aborted at about 16,000
  • parse_xml_tree, which reads the XML without recurring, now returns InvalidMacroData when the elements nest deeper than 256, which keeps every recursion after it within that depth; macros Access makes nest a few levels
  • Split the handling of start tags and of references out of parse_xml_tree, which the check added to

🤖 Generated with Claude Code

dominion525 and others added 2 commits October 20, 2026 09:22
…s an error rather than a stack overflow

- Building the statements of the tree, copying and dropping it, and making its JavaScript objects in Wasm recur on each level; in Wasm, with its 1 MB 
A295
stack, about 2,000 levels of statement groups, some 230 KB of XML, used up the stack and trapped, and the CLI aborted at about 16,000
- parse_xml_tree, which does not recur, returns InvalidMacroData when the elements nest deeper than 256; macros Access makes nest a few levels
- Test that 256 levels read and give their statements, that 257 are an error, and that 100,000 are an error without using up the stack, also on WASI

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- The limit on the depth added to its complexity, so open_element now checks the depth and opens an element at a start tag, and resolve_reference resolves an entity or character reference
- parse_xml_tree goes from a cyclomatic complexity of 25, a cognitive complexity of 15 and 90 lines to 21, 13 and 71

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@dominion525
dominion525 merged commit 4f1eed4 into main Oct 20, 2026
10 checks passed
@dominion525
dominion525 deleted the fix/macro-xml-depth branch October 20, 2026 08:37
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

0