Skip to content

Use lxml's adoptExternalDocument() #239

Open
@scoder

Description

@scoder

It seems that xmlsec's lxml integration does not call adoptExternalDocument() to create an lxml wrapper for an internally created libxml2 XML tree. If it wants to pass externally created XML documents into lxml, then it should call it. Simply wrapping an arbitrary libxml2 tree in an lxml Element violates lxml's tree invariants, such as shared usage of an XML name dict. This can lead to misbehaving elements, such as missing results from .find() (see https://bugs.launchpad.net/lxml/+bug/1960668).

https://github.com/lxml/lxml/blob/95f8006336889df154c45130db1ec897b424e529/src/lxml/includes/etreepublic.pxd#L64-L65

I admit that this is probably un(der)documented, so not your fault.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions