diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2022-11-14 16:43:12 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2022-11-14 16:43:12 +0530 |
commit | d47f8b48935d258f4c5c3e2267911753bebd5214 (patch) | |
tree | 3ed04e75bc3fc7c8e4ce618f527565da1df630a1 /env/lib/python3.10/site-packages/pikepdf/_xml.py | |
parent | 9468226a9e2e2ab8cdd599f1d8538e860ca86120 (diff) | |
download | idcard-d47f8b48935d258f4c5c3e2267911753bebd5214.tar.gz idcard-d47f8b48935d258f4c5c3e2267911753bebd5214.tar.bz2 idcard-d47f8b48935d258f4c5c3e2267911753bebd5214.zip |
id card
Diffstat (limited to 'env/lib/python3.10/site-packages/pikepdf/_xml.py')
-rw-r--r-- | env/lib/python3.10/site-packages/pikepdf/_xml.py | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/env/lib/python3.10/site-packages/pikepdf/_xml.py b/env/lib/python3.10/site-packages/pikepdf/_xml.py deleted file mode 100644 index edf811c..0000000 --- a/env/lib/python3.10/site-packages/pikepdf/_xml.py +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-FileCopyrightText: 2022 James R. Barlow -# SPDX-License-Identifier: MPL-2.0 - -from __future__ import annotations - -from typing import IO, Any, AnyStr - -from lxml.etree import XMLParser as _UnsafeXMLParser -from lxml.etree import _ElementTree -from lxml.etree import parse as _parse - - -class _XMLParser(_UnsafeXMLParser): - def __init__(self, *args: Any, **kwargs: Any): - # Prevent XXE attacks - # https://rules.sonarsource.com/python/type/Vulnerability/RSPEC-2755 - kwargs['resolve_entities'] = False - kwargs['no_network'] = True - super().__init__(*args, **kwargs) - - -def parse_xml(source: AnyStr | IO[Any], recover: bool = False) -> _ElementTree: - """Wrap lxml's parse to provide protection against XXE attacks.""" - parser = _XMLParser(recover=recover, remove_pis=False) - return _parse(source, parser=parser) - - -__all__ = ['parse_xml'] |