Merge branch 'allow-disabling-defusedxml' into 'master'

Do not use defusedxml by default if available

See merge request poezio/slixmpp!190
This commit is contained in:
mathieui 2022-03-20 20:19:54 +01:00
commit e8679fe32b

View File

@ -4,14 +4,18 @@
# This file is part of Slixmpp. # This file is part of Slixmpp.
# See the file LICENSE for copying permission. # See the file LICENSE for copying permission.
import logging import logging
from os import getenv
logging.getLogger(__name__).addHandler(logging.NullHandler()) logging.getLogger(__name__).addHandler(logging.NullHandler())
# Use defusedxml if available # Use defusedxml if wanted
try: # Since enabling it can have adverse consequences for the programs using
import defusedxml # slixmpp, do not enable it by default.
defusedxml.defuse_stdlib() if getenv('SLIXMPP_ENABLE_DEFUSEDXML', default='false').lower() == 'true':
except ImportError: try:
pass import defusedxml
defusedxml.defuse_stdlib()
except ImportError:
pass
from slixmpp.stanza import Message, Presence, Iq from slixmpp.stanza import Message, Presence, Iq
from slixmpp.jid import JID, InvalidJID from slixmpp.jid import JID, InvalidJID