Harden YAML parser against nested structures#6
Merged
Conversation
…rosscheck src/input.c: add a depth-tracking skip_node() so stray nested mappings or sequences (e.g. a top-level array beside `conductors`, or an inner map/seq inside a conductor block) are cleanly skipped instead of throwing the key/value state machine out of parity and aborting with "need at least 2 conductors". tools/fh_crosscheck/geometry.py: coerce nw/nh with round(float(value)) to match the C parser's (int)round(safe_atof(value)), accepting float literals without truncation mismatch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two parsing-robustness fixes surfaced during a static review of the input path.
src/input.c— adds a depth-trackingskip_node()helper. Stray nested mappings/sequences (a top-level array besideconductors, or an inner map/seq inside a conductor block) previously knocked the alternating key/value state machine out of parity, causing the parser to swallow theconductorskey and abort withneed at least 2 conductors. Such nodes are now cleanly skipped.tools/fh_crosscheck/geometry.py— coercesnw/nhwithround(float(value))to match the C parser's(int)round(safe_atof(value)), so float literals likenw: 21.0are accepted with identical rounding (no truncation mismatch).Test plan
python3 -m pytest tools/fh_crosscheck/→ 19 passedNotes
test.yamlwas inadvertently overwritten with a bug-repro fixture during development; it has been restored and is not part of this PR.🤖 Generated with Claude Code