Skip to content

Commit

Permalink
Use defusedxml (#98)
Browse files Browse the repository at this point in the history
* Use defusedxml to parse xml data
* Update npm deps
*  Add dep on defusedxml and update pytest-cov & ruff
  • Loading branch information
bpepple authored Jun 16, 2024
1 parent c76b052 commit 5cf3d5e
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 209 deletions.
6 changes: 4 additions & 2 deletions darkseid/comicinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from re import split
from typing import Any, ClassVar, cast

from defusedxml.ElementTree import fromstring, parse

from darkseid.issue_string import IssueString
from darkseid.metadata import Arc, Basic, Credit, ImageMetadata, Metadata, Role, Series
from darkseid.utils import list_to_string, xlate
Expand Down Expand Up @@ -118,7 +120,7 @@ def metadata_from_string(self: ComicInfo, string: str) -> Metadata:
Metadata: The parsed Metadata object.
"""

tree = ET.ElementTree(ET.fromstring(string)) # noqa: S314
tree = ET.ElementTree(fromstring(string))
return self.convert_xml_to_metadata(tree)

def string_from_metadata(
Expand Down Expand Up @@ -533,5 +535,5 @@ def read_from_external_file(self: ComicInfo, filename: str) -> Metadata:
Metadata: The Metadata object extracted from the file.
"""

tree = ET.parse(filename) # noqa: S314
tree = parse(filename)
return self.convert_xml_to_metadata(tree)
Loading

0 comments on commit 5cf3d5e

Please sign in to comment.