Skip to content

etree.tostring encoding parameter is set to "unicode", which seems to be invalid #395

@borland502

Description

@borland502

bug location in pykeepass.py, line 275

    def xml(self):
        """Get XML part of database as string

        Returns:
            str: XML payload section of database.
        """
        return etree.tostring(
            self.tree,
            pretty_print=True,
            standalone=True,
            encoding='unicode'
        )

To reproduce

        kp_db = PyKeePass(filename=db_path, keyfile=key_path, password=token_path.read_text(encoding="utf-8"))
        # Hack: Take care of what seems to be a bug in pykeepass when exporting xml
        foo = kp_db.xml()  #.replace("encoding=''", "encoding='utf-8'")
        test = pd.read_xml(encoding="utf-8", path_or_buffer=foo)

Pandas will raise an invalid encoding error since the encoding tag is present, but empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions