Skip to content

Commit

Permalink
views: tweak xml rendering to better encoding ampersands. use six for…
Browse files Browse the repository at this point in the history
… string types.
  • Loading branch information
williballenthin committed Dec 18, 2016
1 parent edb2b7d commit 56b8650
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Evtx/Views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import six
import string

from .Nodes import RootNode
Expand Down Expand Up @@ -44,8 +45,7 @@ def __init__(self, msg):


def to_xml_string(s):
#s = xml_sax_escape(s, {'"': '"'})
s = s.encode("ascii", "xmlcharrefreplace").decode('ascii')
s = xml_sax_escape(s, {'"': '"'})
return s


Expand Down Expand Up @@ -154,11 +154,8 @@ def rec(root_node):
f = _make_template_xml_view(root_node, cache=cache)
subs_strs = []
for sub in root_node.fast_substitutions():
# ugly hack for supporting is-string on py2 and py3
if sys.version_info < (3, ) and isinstance(sub, basestring):
subs_strs.append(sub)
elif sys.version_info >= (3, ) and isinstance(sub, str):
subs_strs.append(sub)
if isinstance(sub, six.string_types):
subs_strs.append(sub.replace('&', '&amp;'))
elif isinstance(sub, RootNode):
subs_strs.append(rec(sub))
elif sub is None:
Expand Down

0 comments on commit 56b8650

Please sign in to comment.