Do our best to unpack mojibake'd texture manifests
Some checks failed
CI / linux (map[runner:ubuntu-22.04 target:aarch64]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:armv7]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:ppc64le]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:s390x]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:x86]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:x86_64]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:aarch64]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:armv7]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:x86]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:x86_64]) (push) Has been cancelled
CI / windows (map[python_arch:x64 runner:windows-latest target:x64]) (push) Has been cancelled
CI / windows (map[python_arch:x86 runner:windows-latest target:x86]) (push) Has been cancelled
CI / macos (map[runner:macos-15-intel target:x86_64]) (push) Has been cancelled
CI / macos (map[runner:macos-latest target:aarch64]) (push) Has been cancelled
CI / sdist (push) Has been cancelled
CI / Standalone .exe (Windows x86_64) (push) Has been cancelled
CI / Release (push) Has been cancelled

This commit is contained in:
Will Toohey
2026-07-10 20:06:00 +10:00
parent 90d452014b
commit 76e88275c0
3 changed files with 20 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ build-backend = "maturin"
[project]
name = "ifstools"
version = "2.1"
version = "2.2"
description = "Extractor/repacker for Konmai IFS files"
readme = "README.md"
authors = [

View File

@@ -2,6 +2,7 @@ import os
import lxml.etree as etree
from kbinxml import KBinXML
from kbinxml.kbinxml import KBinException
from .. import utils
from .node import Node
@@ -37,7 +38,12 @@ class GenericFile(Node):
data = self.ifs_data.get(self.start, self.size)
if convert_kbin and self.name.endswith('.xml') and KBinXML.is_binary_xml(data):
data = KBinXML(data).to_text().encode('utf8')
try:
data = KBinXML(data).to_text().encode('utf8')
except KBinException as e:
if 'convert_illegal_things' in e.args[0]:
print("Corrupt xml found, trying to decode as utf8")
data = KBinXML(data, convert_illegal_things=True).to_text().encode('utf8')
return data
def _load_from_filesystem(self, **kwargs):

View File

@@ -1,6 +1,7 @@
from hashlib import md5
from kbinxml import KBinXML
from kbinxml.kbinxml import KBinException
from .generic_folder import GenericFolder
@@ -20,6 +21,7 @@ class MD5Folder(GenericFolder):
self.info_kbin = None
self.info_file = None
self.encoding_override = None
for filename, file in self.files.items():
if filename.endswith('.xml'):
self.info_file = file
@@ -29,7 +31,15 @@ class MD5Folder(GenericFolder):
# _super_ references to info XML breaks things - just extract what we can
return
self.info_kbin = KBinXML(self.info_file.load(convert_kbin = False))
kbin_raw = self.info_file.load(convert_kbin = False)
try:
self.info_kbin = KBinXML(kbin_raw)
except KBinException as e:
if 'convert_illegal_things' in e.args[0]:
print("Corrupt texturelist xml found, trying to decode as utf8")
self.info_kbin = KBinXML(kbin_raw, convert_illegal_things=True)
self.encoding_override = 'utf8'
self._apply_md5()
def _apply_md5(self):
@@ -39,7 +49,7 @@ class MD5Folder(GenericFolder):
def _apply_md5_folder(self, plain_list, folder):
for plain in plain_list:
hashed = md5(plain.encode(self.info_kbin.encoding)).hexdigest()
hashed = md5(plain.encode(self.encoding_override or self.info_kbin.encoding)).hexdigest()
if self.extension:
plain += self.extension