mirror of
https://github.com/Cockatrice/Magic-Spoiler.git
synced 2026-03-21 17:54:59 -05:00
escape some xml values
This commit is contained in:
parent
a73195f022
commit
a242ebb1d1
|
|
@ -20,6 +20,9 @@ SPOILER_SETS: contextvars.ContextVar = contextvars.ContextVar("SPOILER_SETS")
|
|||
|
||||
OUTPUT_DIR = pathlib.Path("out")
|
||||
OUTPUT_TMP_DIR = OUTPUT_DIR.joinpath("tmp")
|
||||
XML_ESCAPE_TRANSLATE_MAP = str.maketrans(
|
||||
{"&": "&", '"': """, "<": "<", ">": ">"}
|
||||
)
|
||||
|
||||
|
||||
def __get_session() -> Union[requests.Session, Any]:
|
||||
|
|
@ -255,6 +258,10 @@ def close_xml_file(card_xml_file: IO[Any]) -> None:
|
|||
f.write(etree.tostring(root, pretty_print=True))
|
||||
|
||||
|
||||
def xml_escape(text):
|
||||
return text.translate(XML_ESCAPE_TRANSLATE_MAP)
|
||||
|
||||
|
||||
def write_cards(
|
||||
card_xml_file: Any, trice_dict: List[Dict[str, Any]], set_code: str
|
||||
) -> None:
|
||||
|
|
@ -333,6 +340,10 @@ def write_cards(
|
|||
if card["layout"] == "split" or card["layout"] == "aftermath":
|
||||
continue
|
||||
|
||||
set_name, mana_cost, card_cmc, card_type, pow_tough, table_row, text = map(
|
||||
xml_escape,
|
||||
[set_name, mana_cost, card_cmc, card_type, pow_tough, table_row, text],
|
||||
)
|
||||
card_xml_file.write("<card>\n")
|
||||
card_xml_file.write("<name>" + set_name + "</name>\n")
|
||||
card_xml_file.write(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user