From e63e3280a1b2d05817e9104784c976ffc086857b Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 29 Sep 2015 06:56:01 -0600 Subject: [PATCH] Prevent launching a packet capture with a non-ASCII path when using Dynamips. --- gns3server/handlers/api/dynamips_vm_handler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gns3server/handlers/api/dynamips_vm_handler.py b/gns3server/handlers/api/dynamips_vm_handler.py index cfb919ba..8bb32bf5 100644 --- a/gns3server/handlers/api/dynamips_vm_handler.py +++ b/gns3server/handlers/api/dynamips_vm_handler.py @@ -16,6 +16,7 @@ # along with this program. If not, see . import os +import sys import base64 from ...web.route import Route @@ -317,6 +318,14 @@ class DynamipsVMHandler: slot_number = int(request.match_info["adapter_number"]) port_number = int(request.match_info["port_number"]) pcap_file_path = os.path.join(vm.project.capture_working_directory(), request.json["capture_file_name"]) + + if sys.platform.startswith('win'): + #FIXME: Dynamips (Cygwin actually) doesn't like non ascii paths on Windows + try: + pcap_file_path.encode('ascii') + except UnicodeEncodeError: + raise DynamipsError('The capture file path "{}" must only contain ASCII (English) characters'.format(pcap_file_path)) + yield from vm.start_capture(slot_number, port_number, pcap_file_path, request.json["data_link_type"]) response.json({"pcap_file_path": pcap_file_path})