mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 06:01:28 +00:00
Ensure UTF-8 encoding used throughout zenmap
This commit is contained in:
@@ -77,17 +77,21 @@ class TargetList(object):
|
||||
self.using_file = True
|
||||
|
||||
# Recovering saved targets
|
||||
target_file = open(self.target_list_file, "r")
|
||||
self.temp_list = [
|
||||
t for t in target_file.read().split(";")
|
||||
if t != "" and t != "\n"]
|
||||
target_file.close()
|
||||
for enc in ('utf-8', None):
|
||||
try:
|
||||
with open(self.target_list_file, "r", encoding=enc) as target_file:
|
||||
self.temp_list = [
|
||||
t for t in target_file.read().split(";")
|
||||
if t != "" and t != "\n"]
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
break
|
||||
else:
|
||||
self.using_file = False
|
||||
|
||||
def save(self):
|
||||
if self.using_file:
|
||||
target_file = open(self.target_list_file, "w")
|
||||
target_file = open(self.target_list_file, "w", encoding="utf-8")
|
||||
target_file.write(";".join(self.temp_list))
|
||||
target_file.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user