1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 05:01:29 +00:00

Prevent UnicodeDecodeError issues in ScriptMetadata

See #3084
This commit is contained in:
dmiller
2025-05-15 17:32:17 +00:00
parent b23300c65a
commit f22bd4b91b

View File

@@ -296,7 +296,7 @@ class ScriptMetadata (object):
self.get_string_variable(filename, "author")]
filepath = os.path.join(self.scripts_dir, filename)
with open(filepath, "r", encoding="utf-8") as f:
with open(filepath, "r", encoding="utf-8", errors="replace") as f:
for tag_name, tag_text in nsedoc_tags_iter(f):
if tag_name == "output" and not entry.output:
entry.output = tag_text
@@ -309,7 +309,7 @@ class ScriptMetadata (object):
@staticmethod
def get_file_contents(filename):
with open(filename, "r", encoding="utf-8") as f:
with open(filename, "r", encoding="utf-8", errors="replace") as f:
contents = f.read()
return contents
@@ -343,7 +343,7 @@ class ScriptMetadata (object):
@staticmethod
def get_requires(filename):
with open(filename, "r", encoding="utf-8") as f:
with open(filename, "r", encoding="utf-8", errors="replace") as f:
requires = ScriptMetadata.get_requires_from_file(f)
return requires
@@ -359,7 +359,7 @@ class ScriptMetadata (object):
@staticmethod
def get_script_args(filename):
with open(filename, "r", encoding="utf-8") as f:
with open(filename, "r", encoding="utf-8", errors="replace") as f:
args = ScriptMetadata.get_script_args_from_file(f)
return args