Fix duplicated <?xml-stylesheet?> processing instruction in XML output#1895
Open
Synvoya wants to merge 1 commit into
Open
Fix duplicated <?xml-stylesheet?> processing instruction in XML output#1895Synvoya wants to merge 1 commit into
<?xml-stylesheet?> processing instruction in XML output#1895Synvoya wants to merge 1 commit into
Conversation
parse_declaration matched any body starting with "<?xml", so a processing instruction whose target merely begins with "xml" (the W3C-standard <?xml-stylesheet?> and <?xml-model?>) was misdetected as the XML declaration. pretty_xml then re-inserted it after toprettyxml had already preserved it, duplicating the instruction. Require the declaration target to be exactly "xml".
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.
Description
The XML formatter duplicated a leading
<?xml-stylesheet?>(or<?xml-model?>) processing instruction in prettified output.parse_declarationaccepted any body starting with<?xml, so a PI whose target merely begins withxml— the two W3C-standard ones,xml-stylesheetandxml-model— was misidentified as the XML declaration.pretty_xmlthen droppedtoprettyxml's generated declaration and re-inserted that "declaration" (the PI), whichtoprettyxmlhad already preserved once, so the instruction appears twice.Fix
Require the declaration target to be exactly
xml(the character after<?xmlmust be whitespace or?), so a<?xml-...?>processing instruction is no longer misdetected.Test
Added
test_xml_leading_processing_instruction_not_duplicated(parametrized overxml-stylesheet/xml-model). All existingtests/test_xml.pypass; reverting only the fix fails the new test.