Skip to content

Commit 4b6c4b1

Browse files
committed
Remove the dependency on defusedxml
1 parent 9825605 commit 4b6c4b1

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ Installation
9292
* [xmlsec](https://pypi.python.org/pypi/xmlsec) Python bindings for the XML Security Library.
9393
* [isodate](https://pypi.python.org/pypi/isodate) An ISO 8601 date/time/
9494
duration parser and formatter
95-
* [defusedxml](https://pypi.python.org/pypi/defusedxml) XML bomb protection for Python stdlib modules
9695

9796
Review the ``setup.py`` file to know the version of the library that ``python3-saml`` is using
9897

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
install_requires=[
4141
'isodate>=0.5.0',
4242
'lxml>=3.3.5',
43-
'xmlsec>=1.0.5',
44-
'defusedxml==0.6.0'
43+
'xmlsec>=1.0.5'
4544
],
4645
dependency_links=['http://github.com/mehcode/python-xmlsec/tarball/master'],
4746
extras_require={

src/onelogin/saml2/xmlparser.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
# Based on the lxml example from defusedxml
4+
# DTDForbidden, EntitiesForbidden, NotSupportedError are clones of the classes defined at defusedxml
45
#
56
# Copyright (c) 2013 by Christian Heimes <christian@python.org>
67
# Licensed to PSF under a Contributor Agreement.
@@ -13,15 +14,51 @@
1314

1415
from lxml import etree as _etree
1516

16-
from defusedxml.lxml import DTDForbidden, EntitiesForbidden, NotSupportedError
17-
1817
LXML3 = _etree.LXML_VERSION[0] >= 3
1918

2019
__origin__ = "lxml.etree"
2120

2221
tostring = _etree.tostring
2322

2423

24+
class DTDForbidden(ValueError):
25+
"""Document type definition is forbidden
26+
"""
27+
28+
def __init__(self, name, sysid, pubid):
29+
super(DTDForbidden, self).__init__()
30+
self.name = name
31+
self.sysid = sysid
32+
self.pubid = pubid
33+
34+
def __str__(self):
35+
tpl = "DTDForbidden(name='{}', system_id={!r}, public_id={!r})"
36+
return tpl.format(self.name, self.sysid, self.pubid)
37+
38+
39+
class EntitiesForbidden(ValueError):
40+
"""Entity definition is forbidden
41+
"""
42+
43+
def __init__(self, name, value, base, sysid, pubid, notation_name):
44+
super(EntitiesForbidden, self).__init__()
45+
self.name = name
46+
self.value = value
47+
self.base = base
48+
self.sysid = sysid
49+
self.pubid = pubid
50+
self.notation_name = notation_name
51+
52+
def __str__(self):
53+
tpl = "EntitiesForbidden(name='{}', system_id={!r}, public_id={!r})"
54+
return tpl.format(self.name, self.sysid, self.pubid)
55+
56+
57+
class NotSupportedError(ValueError):
58+
"""The operation is not supported
59+
"""
60+
61+
2562
class RestrictedElement(_etree.ElementBase):
2663
"""A restricted Element class that filters out instances of some classes
2764
"""

0 commit comments

Comments
 (0)