From f22bd4b91bb629985fce3b93af4e38d1df2247ba Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 15 May 2025 17:32:17 +0000 Subject: [PATCH] Prevent UnicodeDecodeError issues in ScriptMetadata See #3084 --- zenmap/zenmapCore/ScriptMetadata.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zenmap/zenmapCore/ScriptMetadata.py b/zenmap/zenmapCore/ScriptMetadata.py index e30722584..c3316fe34 100644 --- a/zenmap/zenmapCore/ScriptMetadata.py +++ b/zenmap/zenmapCore/ScriptMetadata.py @@ -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