-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #618 from cehbrecht/integrate-lxml-patch
Integrate lxml patch from 4.4 branch
- Loading branch information
Showing
17 changed files
with
95 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from lxml import etree as _etree | ||
|
||
|
||
PARSER = _etree.XMLParser( | ||
resolve_entities=False, | ||
) | ||
|
||
tostring = _etree.tostring | ||
|
||
|
||
def fromstring(text): | ||
return _etree.fromstring(text, parser=PARSER) | ||
|
||
|
||
def parse(source): | ||
return _etree.parse(source, parser=PARSER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ python-dateutil | |
requests | ||
SQLAlchemy | ||
werkzeug | ||
MarkupSafe | ||
humanize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from pywps import xml_util as etree | ||
|
||
from io import StringIO | ||
|
||
|
||
XML_EXECUTE = """ | ||
<!DOCTYPE foo [ | ||
<!ELEMENT foo ANY > | ||
<!ENTITY xxe SYSTEM "file:///PATH/TO/input.txt"> | ||
]> | ||
<wps:Execute | ||
service="WPS" | ||
version="1.0.0" | ||
xmlns:wps="http://www.opengis.net/wps/1.0.0" | ||
xmlns:ows="http://www.opengis.net/ows/1.1" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://schemas.opengis.net/wps/1.0.0/wpsExecute_request.xsd"> | ||
<ows:Identifier>test_process</ows:Identifier> | ||
<wps:DataInputs> | ||
<wps:Input> | ||
<ows:Identifier>name</ows:Identifier> | ||
<wps:Data> | ||
<wps:LiteralData>&xxe;</wps:LiteralData> | ||
</wps:Data> | ||
</wps:Input> | ||
</wps:DataInputs> | ||
<wps:ResponseForm> | ||
<wps:ResponseDocument | ||
storeExecuteResponse="true" | ||
status="true"> | ||
<wps:Output asReference="false"> | ||
<ows:Identifier>output</ows:Identifier> | ||
</wps:Output> | ||
</wps:ResponseDocument> | ||
</wps:ResponseForm> | ||
</wps:Execute> | ||
""" | ||
|
||
|
||
def test_etree_fromstring(): | ||
xml = etree.tostring(etree.fromstring(XML_EXECUTE)) | ||
# don't replace entities | ||
# https://lxml.de/parsing.html | ||
assert b"<wps:LiteralData>&xxe;</wps:LiteralData>" in xml | ||
|
||
|
||
def test_etree_parse(): | ||
xml = etree.tostring(etree.parse(StringIO(XML_EXECUTE))) | ||
# don't replace entities | ||
# https://lxml.de/parsing.html | ||
assert b"<wps:LiteralData>&xxe;</wps:LiteralData>" in xml |