summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-11 20:23:11 +0100
committermathieui <mathieui@mathieui.net>2021-02-11 20:23:11 +0100
commit53dc9847e2a4110be85ad16af9b427f9a280aaee (patch)
treeae0c80caf7e8da1aa11ec5932b4e8da51af9b57c
parentbfbc433c8d0497b14b649a5fb1c3ee5789f9f63f (diff)
downloadslixmpp-53dc9847e2a4110be85ad16af9b427f9a280aaee.tar.gz
slixmpp-53dc9847e2a4110be85ad16af9b427f9a280aaee.tar.bz2
slixmpp-53dc9847e2a4110be85ad16af9b427f9a280aaee.tar.xz
slixmpp-53dc9847e2a4110be85ad16af9b427f9a280aaee.zip
global: use defusedxml if it is available
-rwxr-xr-xsetup.py1
-rw-r--r--slixmpp/__init__.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index f30380a3..06645e69 100755
--- a/setup.py
+++ b/setup.py
@@ -87,6 +87,7 @@ setup(
extras_require={
'XEP-0363': ['aiohttp'],
'XEP-0444 compliance': ['emoji'],
+ 'Safer XML parsing': ['defusedxml'],
},
classifiers=CLASSIFIERS,
cmdclass={'test': TestCommand}
diff --git a/slixmpp/__init__.py b/slixmpp/__init__.py
index 1badccb6..769a9e31 100644
--- a/slixmpp/__init__.py
+++ b/slixmpp/__init__.py
@@ -6,6 +6,13 @@
import logging
logging.getLogger(__name__).addHandler(logging.NullHandler())
+# Use defusedxml if available
+try:
+ import defusedxml
+ defusedxml.defuse_stdlib()
+except ImportError:
+ pass
+
from slixmpp.stanza import Message, Presence, Iq
from slixmpp.jid import JID, InvalidJID
from slixmpp.xmlstream.stanzabase import ET, ElementBase, register_stanza_plugin