Skip to content

Commit

Permalink
strip unknown xml elements when parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
futzu authored Nov 27, 2024
1 parent b2c99ac commit 5bbf77c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions threefive/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ class XmlParser:
def __init__(self):
self.active = None
self.node_list = []
self.open_nodes=[]
self.parent=None

def chk_node_list(self, node):
"""
Expand All @@ -403,10 +405,12 @@ def mk_active(self, node):
"""
mk_active sets self.active to the current node name.
"""
self.active=None
name = node[1:].split(" ", 1)[0].split(">", 1)[0]
name = strip_ns(name)
self.active = name.replace("/", "").replace(">", "")


def _split_attrs(self, node):
node = node.replace("='", '="').replace("' ", '" ')
attrs = [x for x in node.split(" ") if "=" in x]
Expand All @@ -430,7 +434,9 @@ def parse(self, exemel, descriptor_parse=False):
"""
parse parses an xml string for a SCTE-35 Cue.
"""
stuff = {"descriptors": []}
stuff={}
if not descriptor_parse:
stuff = {"descriptors": []}
data = exemel.replace("\n", "").strip()
while ">" in data:
self.mk_active(data)
Expand All @@ -453,7 +459,8 @@ def _parse_most(self, data, stuff):
self.chk_node_list(this_node)
attrs = self.mk_attrs(this_node)
if self.active not in stuff:
stuff[self.active] = attrs
if self.active not in ['!--','']:
stuff[self.active] = attrs
data = data[ridx + 1 :]
if "<" in data:
lidx = data.index("<")
Expand Down

0 comments on commit 5bbf77c

Please sign in to comment.