1
0
mirror of synced 2025-02-17 11:18:33 +01:00

Fix weird filename edgecase with some ifs file.

This commit is contained in:
Jennifer Taylor 2021-10-24 17:12:06 +00:00
parent c4a5abaf4d
commit 495466f4e4
2 changed files with 6 additions and 1 deletions

View File

@ -196,6 +196,11 @@ class IFS:
name = subchild.attribute('name')
if name is None:
raise Exception(f"Texture entry {subchild} has no name!")
if ' ' in name:
# Certain files that were corrupted on create or copy
# seem to have spaces in the name which shouldn't be
# allowed. Lob them off.
name = name[:name.find(' ')]
md5sum = hashlib.md5(name.encode(encoding)).hexdigest()
oldname = os.path.join(texdir, md5sum)
newname = os.path.join(texdir, name)

View File

@ -422,7 +422,7 @@ class BinaryDecoder:
# Need to convert this from encoding to standard string.
# Also, need to lob off the trailing null.
try:
val = val[:-1].decode(self.encoding)
val = val[:-1].decode(self.encoding, 'replace')
except UnicodeDecodeError:
# Nothing we can do here
pass