Better handling of special characters when saving a timeline

This commit is contained in:
Nex
2021-07-21 11:53:41 +02:00
parent 2f05d4b4f9
commit 8d68e7a166

View File

@@ -3,6 +3,7 @@
# See the file 'LICENSE' for usage and copying permissions, or find a copy at
# https://github.com/mvt-project/mvt/blob/main/LICENSE
import io
import os
import re
import csv
@@ -160,7 +161,7 @@ def save_timeline(timeline, timeline_path):
:param timeline: List of records to order and store.
:param timeline_path: Path to the csv file to store the timeline to.
"""
with open(timeline_path, "a+") as handle:
with io.open(timeline_path, "a+", encoding="utf-8") as handle:
csvoutput = csv.writer(handle, delimiter=",", quotechar="\"")
csvoutput.writerow(["UTC Timestamp", "Plugin", "Event", "Description"])
for event in sorted(timeline, key=lambda x: x["timestamp"] if x["timestamp"] is not None else ""):