mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-29 10:16:52 +00:00
use defusedxml for sax.parse().
This commit is contained in:
parent
f1dff44d3a
commit
ccf427b4a0
2 changed files with 6 additions and 1 deletions
|
|
@ -4,6 +4,10 @@ import argparse
|
|||
import xml.sax.handler
|
||||
from collections.abc import Sequence
|
||||
|
||||
import defusedxml
|
||||
|
||||
defusedxml.defuse_stdlib()
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
|
|
@ -15,7 +19,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|||
for filename in args.filenames:
|
||||
try:
|
||||
with open(filename, 'rb') as xml_file:
|
||||
xml.sax.parse(xml_file, handler)
|
||||
defusedxml.sax.parse(xml_file, handler)
|
||||
except xml.sax.SAXException as exc:
|
||||
print(f'{filename}: Failed to xml parse ({exc})')
|
||||
retval = 1
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ classifiers =
|
|||
[options]
|
||||
packages = find:
|
||||
install_requires =
|
||||
defusedxml>=0.7.1
|
||||
ruamel.yaml>=0.15
|
||||
tomli>=1.1.0;python_version<"3.11"
|
||||
python_requires = >=3.10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue