diff --git a/lib/galaxy/util/__init__.py b/lib/galaxy/util/__init__.py index 0db936efc525..607207eb872c 100644 --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -1194,25 +1194,6 @@ def unicodify( return value -def decodify(value, encoding="utf-8", encoding_error="replace", decoding="latin-1", decoding_error="replace"): - """ - Returns a Unicode string or None. - """ - if value is None: - return value - - if isinstance(value, bytes): - return value.decode(decoding, decoding_error) - - if isinstance(value, str): - return value.encode(encoding, encoding_error).decode(decoding, decoding_error) - - if not isinstance(value, (str, bytes)): - value = str(value) - - return value - - def filesystem_safe_string( s, max_len=255, truncation_chars="..", strip_leading_dot=True, invalid_chars=("/",), replacement_char="_" ): diff --git a/lib/galaxy/util/zipstream.py b/lib/galaxy/util/zipstream.py index 0b1358166b68..5fa8bc0909b2 100644 --- a/lib/galaxy/util/zipstream.py +++ b/lib/galaxy/util/zipstream.py @@ -11,7 +11,6 @@ import zipstream -from galaxy.util import decodify from .path import safe_walk CRC32_MIN = 1444 @@ -42,7 +41,8 @@ def response(self) -> Iterator[bytes]: def get_headers(self) -> Dict[str, str]: headers = {} if self.archive_name: - headers["Content-Disposition"] = f'attachment; filename="{decodify(self.archive_name)}.zip"' + archive_name = self.archive_name.encode("utf-8", "replace").decode("latin-1") + headers["Content-Disposition"] = f'attachment; filename="{archive_name}.zip"' if self.upstream_mod_zip: headers["X-Archive-Files"] = "zip" else: diff --git a/test/unit/util/test_utils.py b/test/unit/util/test_utils.py index bb6000623c39..81d448dd4a1a 100644 --- a/test/unit/util/test_utils.py +++ b/test/unit/util/test_utils.py @@ -139,14 +139,3 @@ class Stuff(str, Enum): B = "b" assert util.enum_values(Stuff) == ["a", "c", "b"] - - -def test_decodify(): - assert util.decodify(None) is None - assert util.decodify("simple string") == "simple string" - assert util.decodify(3) == "3" - assert util.decodify(Exception("strĩñg")) == "strĩñg" - s = "lâtín strìñg" - assert util.decodify(s, encoding="latin-1") == s - s = "تست" - assert util.decodify(s, decoding="utf-8") == s