Skip to content

Commit 6ccc796

Browse files
jhelmoldbjoernricks
authored andcommitted
Fix: Made the script "export-xml-report.gmp.py" work.
1 parent a62831a commit 6ccc796

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

scripts/export-xml-report.gmp.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from gvm.protocols.gmp import Gmp
1111
from gvm.xml import pretty_print
12+
from lxml import etree
1213

1314

1415
def check_args(args):
@@ -51,9 +52,8 @@ def main(gmp: Gmp, args: Namespace) -> None:
5152
)
5253

5354
report_element = response.find("report")
54-
pretty_print(report_element)
55-
# get the full content of the report element
56-
content = report_element.find("report_format").tail
55+
# get the full content of the report element as bytestring
56+
content = etree.tostring(report_element.find("report"))
5757

5858
if not content:
5959
print(
@@ -64,16 +64,13 @@ def main(gmp: Gmp, args: Namespace) -> None:
6464
)
6565
sys.exit(1)
6666

67-
# convert content to 8-bit ASCII bytes
68-
binary_base64_encoded_xml = content.encode("ascii")
69-
70-
# decode base64
71-
binary_xml = b64decode(binary_base64_encoded_xml)
67+
# decode content
68+
dcontent = content.decode("utf-8")
7269

7370
# write to file and support ~ in filename path
7471
xml_path = Path(xml_filename).expanduser()
7572

76-
xml_path.write_bytes(binary_xml)
73+
xml_path.write_text(dcontent)
7774

7875
print("Done. xml created: " + str(xml_path))
7976

0 commit comments

Comments
 (0)