Skip to content

Commit 64ae356

Browse files
committed
Document huge_tree.
1 parent 3b9c10f commit 64ae356

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ History
1010
* Support for Python 2.7, 3.5 and 3.6 is removed
1111
* Support for Python 3.9-3.11 is added
1212
* Very large documents (with deep nesting or long tag content) can now be
13-
parsed
13+
parsed, and ``Selector`` now takes a new argument ``huge_tree`` to disable
14+
this
1415
* Support for new features of cssselect 1.2.0 is added
1516
* The ``Selector.remove()`` and ``SelectorList.remove()`` methods are
1617
deprecated and replaced with the new ``Selector.drop()`` and

parsel/selector.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ class Selector:
269269
270270
``base_url`` allows setting a URL for the document. This is needed when looking up external entities with relative paths.
271271
See the documentation for :func:`lxml.etree.fromstring` for more information.
272+
273+
``huge_tree`` controls the lxml/libxml2 feature that forbids parsing
274+
certain large documents to protect from possible memory exhaustion. The
275+
argument is ``True`` by default if the installed lxml version supports it,
276+
which disables the protection to allow parsing such documents. Set it to
277+
``False`` if you want to enable the protection.
278+
See `this lxml FAQ entry <https://lxml.de/FAQ.html#is-lxml-vulnerable-to-xml-bombs>`_
279+
for more information.
272280
"""
273281

274282
__slots__ = [

0 commit comments

Comments
 (0)