Skip to content

Commit b65d192

Browse files
author
Willi Ballenthin
committed
views: fix encoding of subs
1 parent abdf69e commit b65d192

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Evtx/Views.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ def rec(node, acc):
127127
return "".join(acc)
128128

129129

130+
def to_xml_string(s):
131+
s = xml_sax_escape(s, {'"': '"'})
132+
s = s.encode("ascii", "xmlcharrefreplace").decode('ascii')
133+
return s
134+
135+
130136
def _build_record_xml(record, cache=None):
131137
"""
132138
Note, the cache should be local to the Evtx.Chunk.
@@ -144,7 +150,7 @@ def rec(root_node):
144150
subs_strs = []
145151
for sub in root_node.fast_substitutions():
146152
if isinstance(sub, str):
147-
subs_strs.append((xml_sax_escape(sub, {'"': """})).encode("ascii", "xmlcharrefreplace"))
153+
subs_strs.append(to_xml_string(sub))
148154
elif isinstance(sub, RootNode):
149155
subs_strs.append(rec(sub))
150156
elif sub is None:

0 commit comments

Comments
 (0)