Repository navigation
fix: fall back to len(children) on malformed numchildren - #124
Merged
Merged
Conversation
Closes #100 A non-numeric or overflowing numchildren attribute made the whole DBGp response fail to parse, because encoding/xml decodes struct integer attributes strictly and rawLocked treats any parse error as fatal. Before #35 the attribute was unknown to the decoder and so was ignored; #98 reintroduced it as a strict int, turning a cosmetic engine quirk into a hard command failure. xProp now decodes numchildren leniently: a malformed or out-of-range value falls back to 0, and summarize's max(p.NumChildren, len(p.Children)) then reports the received page size. A type-level UnmarshalXMLAttr is not enough on its own — it makes the int fields opaque to the decoder — so xProp also implements UnmarshalXML to bind the remaining fields through a shadow struct, keeping nested property decoding intact. Tests cover malformed, negative and overflowing values.
Member
|
Thank you @Furox-Art for this fix! I added a CHANGELOG entry, space trimming and a nested test on top, and merged it. |
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.
Closes #100
What
numchildren="abc"(or an overflowing value) madeencoding/xmlfail the whole response, becausexProp.NumChildrenis a strictintandrawLockedtreats any parse error as fatal — a cosmetic engine quirk became a hard command failure. #98 reintroduced the attribute as a strict int; before #35 it was unknown to the decoder and ignored.xPropnow decodesnumchildrenleniently: a malformed or out-of-range value falls back to0, andsummarize's existingmax(p.NumChildren, len(p.Children))reports the received page size.A type-level
UnmarshalXMLAttralone is not sufficient — it makes the struct's int fields opaque to the decoder — soxPropalso implementsUnmarshalXML, binding the remaining fields through a shadow struct. Nested property decoding is unchanged.Tests
New cases in
dbgp_test.gocover malformed ("abc"), negative (-5) and overflowing (99999999999999999999999) values: each parses without error and renders the received page size.Note on the full suite
TestToolsCallListenBadInitfails in this environment, but it fails identically on a pristinemaincheckout (verified withgit stash— same subtests, same "no engine connected within 10s" error). It looks network/timing-dependent in WSL, not related to this change. CI on GitHub's runners is the authoritative gate.