Skip to content

fix: skip DOMDocumentType when importing XML with DOCTYPE declaration#71

Open
guillaumedelre wants to merge 1 commit into
downforcetech:mainfrom
guillaumedelre:fix/issue-44
Open

fix: skip DOMDocumentType when importing XML with DOCTYPE declaration#71
guillaumedelre wants to merge 1 commit into
downforcetech:mainfrom
guillaumedelre:fix/issue-44

Conversation

@guillaumedelre
Copy link
Copy Markdown

DOMDocument::importNode() returns false for DOMDocumentType nodes, causing appendChild() to receive a boolean and throw a fatal error.

This happens when loading or inserting XML that contains a <!DOCTYPE> declaration: the node list from childNodes includes the DOMDocumentType node alongside the root element.

Skip DOMDocumentType entries in attachNodes() before attempting the import, so the document content is imported correctly and the DOCTYPE declaration is silently discarded.

Fixes #44
Fixes #50

DOMDocument::importNode() returns false for DOMDocumentType nodes,
causing appendChild() to receive a boolean and throw a fatal error.

This happens when loading or inserting XML that contains a <!DOCTYPE>
declaration: the node list from childNodes includes the DOMDocumentType
node alongside the root element.

Skip DOMDocumentType entries in attachNodes() before attempting the
import, so the document content is imported correctly and the DOCTYPE
declaration is silently discarded.

Fixes downforcetech#44
Fixes downforcetech#50

Signed-off-by: Guillaume Delré <delre.guillaume@gmail.com>
@guillaumedelre
Copy link
Copy Markdown
Author

Hey @daniele-orlando, this PR fixes #44 and #50 — happy to adjust if anything looks off.

@guillaumedelre
Copy link
Copy Markdown
Author

Hey @daniele-orlando, gentle ping on this one. Let me know if you'd prefer a different fix.

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.

Error reading fcpxml file Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, bool given

1 participant