replace xml parsers with defusedxml versions

security-update
Andrew Port 2021-09-21 01:54:58 -07:00
parent 0a31f348d6
commit da050a2eeb
5 changed files with 8 additions and 4 deletions

View File

@ -1,2 +1,3 @@
numpy numpy
svgwrite svgwrite
defusedxml

View File

@ -39,7 +39,7 @@ import os
import collections import collections
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
from xml.etree.ElementTree import Element, SubElement, register_namespace from xml.etree.ElementTree import Element, SubElement, register_namespace
from xml.dom.minidom import parseString from defusedxml.minidom import parseString
import warnings import warnings
from tempfile import gettempdir from tempfile import gettempdir
from time import time from time import time

View File

@ -8,7 +8,7 @@ from __future__ import division, absolute_import, print_function
from math import ceil from math import ceil
from os import path as os_path, makedirs from os import path as os_path, makedirs
from tempfile import gettempdir from tempfile import gettempdir
from xml.dom.minidom import parse as md_xml_parse from defusedxml.minidom import parse as md_xml_parse
from svgwrite import Drawing, text as txt from svgwrite import Drawing, text as txt
from time import time from time import time
from warnings import warn from warnings import warn

View File

@ -5,7 +5,8 @@
# External dependencies # External dependencies
from __future__ import division, absolute_import, print_function from __future__ import division, absolute_import, print_function
import os import os
from xml.etree.ElementTree import iterparse, Element, ElementTree, SubElement from xml.etree.ElementTree import Element, ElementTree, SubElement
from defusedxml.cElementTree import iterparse
# Internal dependencies # Internal dependencies
from .parser import parse_path from .parser import parse_path

View File

@ -3,7 +3,7 @@ The main tool being the svg2paths() function."""
# External dependencies # External dependencies
from __future__ import division, absolute_import, print_function from __future__ import division, absolute_import, print_function
from xml.dom.minidom import parse from defusedxml.minidom import parse
from os import path as os_path, getcwd from os import path as os_path, getcwd
import re import re
@ -17,9 +17,11 @@ COORD_PAIR_TMPLT = re.compile(
r'([\+-]?\d*[\.\d]\d*[eE][\+-]?\d+|[\+-]?\d*[\.\d]\d*)' r'([\+-]?\d*[\.\d]\d*[eE][\+-]?\d+|[\+-]?\d*[\.\d]\d*)'
) )
def path2pathd(path): def path2pathd(path):
return path.get('d', '') return path.get('d', '')
def ellipse2pathd(ellipse): def ellipse2pathd(ellipse):
"""converts the parameters from an ellipse or a circle to a string for a """converts the parameters from an ellipse or a circle to a string for a
Path object d-attribute""" Path object d-attribute"""