diff --git a/cuckoo/cuckoo_main.py b/cuckoo/cuckoo_main.py index 969eee3..8bca6cf 100644 --- a/cuckoo/cuckoo_main.py +++ b/cuckoo/cuckoo_main.py @@ -1084,6 +1084,9 @@ def _remove_illegal_characters_from_file_name(self) -> None: self.log.debug(f"Renaming {self.file_name} because it contains one of {ILLEGAL_FILENAME_CHARS}") self.file_name = ''.join(ch for ch in self.file_name if ch not in ILLEGAL_FILENAME_CHARS) + if self.file_name.startswith(" "): + self.file_name = self.file_name.lstrip() + def _assign_file_extension(self, kwargs: Dict[str, Any]) -> str: """ This method determines the correct file extension to the file to be submitted diff --git a/tests/test_cuckoo_main.py b/tests/test_cuckoo_main.py index 6f29bdb..367fe1d 100644 --- a/tests/test_cuckoo_main.py +++ b/tests/test_cuckoo_main.py @@ -1082,7 +1082,7 @@ def test_decode_mime_encoded_file_name(test_file_name, correct_file_name, cuckoo @staticmethod def test_remove_illegal_characters_from_file_name(cuckoo_class_instance): - test_file_name = ''.join(ch for ch in ILLEGAL_FILENAME_CHARS) + "blah" + test_file_name = " " + ''.join(ch for ch in ILLEGAL_FILENAME_CHARS) + "blah" correct_file_name = "blah" cuckoo_class_instance.file_name = test_file_name