Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
49 lines (40 loc) · 1.42 KB

File metadata and controls

49 lines (40 loc) · 1.42 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
from defusedxml import DTDForbidden, EntitiesForbidden
from pytest import raises as assert_raises
from tests.utils import DummyTransport
from zeep.loader import parse_xml
from zeep.settings import Settings
def test_huge_text():
# libxml2>=2.7.3 has XML_MAX_TEXT_LENGTH 10000000 without XML_PARSE_HUGE
settings = Settings(xml_huge_tree=True)
tree = parse_xml(
u"""
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<HugeText xmlns="http://hugetext">%s</HugeText>
</s:Body>
</s:Envelope>
"""
% (u"\u00e5" * 10000001),
DummyTransport(),
settings=settings,
)
assert tree[0][0].text == u"\u00e5" * 10000001
def test_allow_entities_and_dtd():
xml = u"""
<!DOCTYPE Author [
<!ENTITY writer "Donald Duck.">
]>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Author>&writer;</Author>
</s:Body>
</s:Envelope>
"""
# DTD is allowed by default in defusexml so we follow this behaviour
with pytest.raises(DTDForbidden):
parse_xml(xml, DummyTransport(), settings=Settings(forbid_dtd=True))
with pytest.raises(EntitiesForbidden):
parse_xml(xml, DummyTransport())
tree = parse_xml(xml, DummyTransport(), settings=Settings(forbid_entities=False))
assert tree[0][0].tag == "Author"
Morty Proxy This is a proxified and sanitized view of the page, visit original site.