From 5fdc88493c65b9426cabaf731581f65690139d03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu>
Date: Thu, 26 Jan 2017 16:35:54 +0100
Subject: [PATCH] Removed invalid chars from attachment.

---
 tester.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tester.py b/tester.py
index 295f4061..a7ebff49 100755
--- a/tester.py
+++ b/tester.py
@@ -6,6 +6,7 @@ Script to start tests and to manage their results
 from io import StringIO
 import datetime
 import os
+import re
 import subprocess
 import sys
 import uuid
@@ -159,6 +160,7 @@ class Tester():
                 return 1
             boundary = str(uuid.uuid4())
             now = datetime.datetime.utcnow()
+            log_content = re.sub(r'\033\[[\d;]+m', '', log_buffer.getvalue())
             mail = '''From: %(hostname)s <noreply@ubicast.eu>
 To: %(recipients)s
 Subject: UbiCast application test: %(status)s
@@ -173,7 +175,7 @@ Content-transfer-encoding: utf-8
 %(report)s
 
 --%(boundary)s
-Content-type: text/plain; name="%(log_name)s"
+Content-type: text/plain; name="%(log_name)s"; charset=UTF-8
 Content-disposition: attachment; filename="%(log_name)s"
 Content-transfer-encoding: utf-8
 
@@ -186,7 +188,7 @@ Content-transfer-encoding: utf-8
                 date=now.strftime('%Y-%m-%d %H:%M:%S'),
                 log_name='results_' + now.strftime('%Y-%m-%d_%H-%M-%S') + '.txt',
                 report=html_report,
-                log_content=log_buffer.getvalue(),
+                log_content=log_content,
             )
             p = subprocess.Popen(['sendmail', '-t'], stdin=subprocess.PIPE, stdout=sys.stdout.stream, stderr=sys.stderr.stream)
             p.communicate(input=mail.encode('utf-8'))
-- 
GitLab