1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 06:01:28 +00:00

Zenmap: Ensure files are opened with UTF-8 encoding

This commit is contained in:
dmiller
2025-03-04 17:06:32 +00:00
parent 068dd4b0df
commit 49c25e6431
3 changed files with 6 additions and 5 deletions

View File

@@ -121,7 +121,7 @@ class NdiffCommand(subprocess.Popen):
filename_b filename_b
] ]
self.stdout_file = tempfile.TemporaryFile( self.stdout_file = tempfile.TemporaryFile(
mode="r", mode="r", encoding="utf-8",
prefix=APP_NAME + "-ndiff-", prefix=APP_NAME + "-ndiff-",
suffix=".xml" suffix=".xml"
) )
@@ -131,7 +131,7 @@ class NdiffCommand(subprocess.Popen):
subprocess.Popen.__init__( subprocess.Popen.__init__(
self, self,
command_list, command_list,
universal_newlines=True, universal_newlines=True, encoding="utf-8",
stdout=self.stdout_file, stdout=self.stdout_file,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
env=env, env=env,

View File

@@ -198,7 +198,7 @@ class NmapCommand(object):
# We don't need a file name for stdout output, just a handle. A # We don't need a file name for stdout output, just a handle. A
# TemporaryFile is deleted as soon as it is closed, and in Unix is # TemporaryFile is deleted as soon as it is closed, and in Unix is
# unlinked immediately after creation so it's not even visible. # unlinked immediately after creation so it's not even visible.
f = tempfile.TemporaryFile(mode="r", prefix=APP_NAME + "-stdout-") f = tempfile.TemporaryFile(mode="r", prefix=APP_NAME + "-stdout-", encoding="utf-8")
self.stdout_file = f self.stdout_file = f
if stderr is None: if stderr is None:
stderr = f stderr = f
@@ -223,7 +223,7 @@ class NmapCommand(object):
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
self.command_process = subprocess.Popen(command_list, bufsize=1, self.command_process = subprocess.Popen(command_list, bufsize=1,
universal_newlines=True, universal_newlines=True, encoding="utf-8",
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=f, stdout=f,
stderr=stderr, stderr=stderr,

View File

@@ -226,7 +226,8 @@ class ScriptInterface:
# Separate stderr to avoid breaking XML parsing with "Warning: File # Separate stderr to avoid breaking XML parsing with "Warning: File
# ./nse_main.lua exists, but Nmap is using...". # ./nse_main.lua exists, but Nmap is using...".
stderr = tempfile.TemporaryFile( stderr = tempfile.TemporaryFile(
mode="r", prefix=APP_NAME + "-script-help-stderr-") mode="r", prefix=APP_NAME + "-script-help-stderr-",
encoding="utf-8")
log.debug("Script interface: running %s" % repr(command_string)) log.debug("Script interface: running %s" % repr(command_string))
nmap_process = NmapCommand(command_string) nmap_process = NmapCommand(command_string)
try: try: