From a032960b4fb8e50386fa02739b6b107b233b64ca Mon Sep 17 00:00:00 2001
From: Gabriel Becker <ggasparb@redhat.com>
Date: Mon, 2 Aug 2021 18:39:58 +0200
Subject: [PATCH] Fix a python2 issue with STIG overlay generation.
---
utils/create-stig-overlay.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/utils/create-stig-overlay.py b/utils/create-stig-overlay.py
index 02deb0b5b2..5d4bb835ca 100755
--- a/utils/create-stig-overlay.py
+++ b/utils/create-stig-overlay.py
@@ -107,7 +107,12 @@ def new_stig_overlay(xccdftree, ssgtree, outfile, quiet):
lines = new_stig_overlay.findall("overlay")
new_stig_overlay[:] = sorted(lines, key=getkey)
- dom = xml.dom.minidom.parseString(ET.tostring(new_stig_overlay, encoding="UTF-8", xml_declaration=True))
+ try:
+ et_str = ET.tostring(new_stig_overlay, encoding="UTF-8", xml_declaration=True)
+ except TypeError:
+ et_str = ET.tostring(new_stig_overlay, encoding="UTF-8")
+
+ dom = xml.dom.minidom.parseString(et_str)
pretty_xml_as_string = dom.toprettyxml(indent=' ', encoding="UTF-8")
overlay_directory = os.path.dirname(outfile)