Skip to content

Commit

Permalink
Merge pull request #323 from nosnilmot/lxml-workaround
Browse files Browse the repository at this point in the history
Remove lxml version restriction
  • Loading branch information
pitbulk authored Dec 23, 2022
2 parents 96ad99e + 01a154c commit e3d3539
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Installation

* python 2.7 // python 3.6
* [xmlsec](https://pypi.python.org/pypi/xmlsec) Python bindings for the XML Security Library.
* [lxml](https://pypi.python.org/pypi/lxml) Python bindings for the libxml2 and libxslt libraries.
* [isodate](https://pypi.python.org/pypi/isodate) An ISO 8601 date/time/
duration parser and formatter

Expand Down Expand Up @@ -115,6 +116,14 @@ $ pip install python3-saml

If you want to know how a project can handle python packages review this [guide](https://packaging.python.org/en/latest/tutorial.html) and review this [sampleproject](https://github.com/pypa/sampleproject)

#### NOTE ####
To avoid ``libxml2`` library version incompatibilities between ``xmlsec`` and ``lxml`` it is recommended that ``lxml`` is not installed from binary.

This can be ensured by executing:
```
$ pip install --force-reinstall --no-binary lxml lxml
```

Security Warning
----------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
test_suite='tests',
install_requires=[
'lxml<4.7.1',
'lxml>=4.6.5',
'isodate>=0.6.1',
'xmlsec>=1.3.9'
],
Expand Down
24 changes: 24 additions & 0 deletions tests/src/OneLogin/saml2_tests/xml_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import json
import unittest
import xmlsec

from base64 import b64decode
from lxml import etree
Expand Down Expand Up @@ -32,6 +33,29 @@ def file_contents(self, filename):
f.close()
return content

def testLibxml2(self):
"""
Tests that libxml2 versions used by xmlsec and lxml are compatible
If this test fails, reinstall lxml without using binary to ensure it is
linked to same version of libxml2 as xmlsec:
pip install --force-reinstall --no-binary lxml lxml
See https://bugs.launchpad.net/lxml/+bug/1960668
"""
env = etree.fromstring('<xml></xml>')
sig = xmlsec.template.create(
env,
xmlsec.Transform.EXCL_C14N,
xmlsec.Transform.RSA_SHA256,
ns="ds"
)

ds = etree.QName(sig).namespace
cm = sig.find(".//{%s}CanonicalizationMethod" % ds)

self.assertIsNotNone(cm)

def testValidateXML(self):
"""
Tests the validate_xml method of the OneLogin_Saml2_XML
Expand Down

0 comments on commit e3d3539

Please sign in to comment.