Skip to content

Print XML through non-XML formatters without re-parenting - #190

Open
Shaisolaris wants to merge 2 commits into
trailofbits:masterfrom
Shaisolaris:issue-187
Open

Shaisolaris wants to merge 2 commits into
trailofbits:masterfrom
Shaisolaris:issue-187

Conversation

@Shaisolaris

Copy link
Copy Markdown

Fixes #187

_json_print_XMLElement wrapped live tag, attribute, text, and child nodes in a new DictNode. Those nodes already had a parent, so the first KeyValuePairNode raised ValueError for every non-XML output format.

The JSON view now copies those nodes and builds a dict it owns. YAML uses the same printer, because its ContainerNode fallback hit the same parent check.

Tests render a small XML and HTML tree through each registered formatter and cover a JSON-formatted XML diff.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ESultanik

Copy link
Copy Markdown
Collaborator

@Shaisolaris thank you for this one as well. I reproduced the crash on current master before reviewing:

$ graphtage --no-status --no-color --format json a.xml b.xml
ValueError: Error while setting EditedStringNode('r').parent = KeyValuePairNode(...): Parent is already assigned

Same as with #189, I'd like to get this into the next release, but we do need your CLA signature first. If it comes
through in the next few days both fixes ship in 0.5.0; otherwise they roll into the following release.

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.

Diffing XML or HTML to any non-XML output format crashes

3 participants