fix: strip leading UTF-8 BOM in parse_mod_info
mod.info files saved by Windows notepad start with a U+FEFF BOM, which made the first line's `name=` regex miss; affected mods displayed with empty name (sort still worked because `id=` on subsequent lines parsed fine, but MOD_DB display name fell back to mod_id). Both copies of mlos_sort.py updated; existing 23 BOM-affected rows already cleaned in place from raw_mod_info.
This commit is contained in:
@@ -227,6 +227,12 @@ def parse_mod_info(text: str, workshop_id: Optional[str] = None) -> Optional[Mod
|
||||
Parse a mod.info file body. Returns None if no `id=` line found.
|
||||
Lines are `key=value`; keys lowercased; list-fields comma-separated.
|
||||
"""
|
||||
# Strip a leading UTF-8 BOM if present. Some authors save mod.info with
|
||||
# BOM (notepad.exe default on Windows); without this, the first line's
|
||||
# `name=` regex misses because the line starts with U+FEFF instead of
|
||||
# `n`, leaving the mod with an empty display name even though `id=` on
|
||||
# subsequent lines parses fine.
|
||||
text = text.lstrip("")
|
||||
fields: Dict[str, object] = {}
|
||||
for raw in text.splitlines():
|
||||
line = raw.strip()
|
||||
|
||||
@@ -227,6 +227,12 @@ def parse_mod_info(text: str, workshop_id: Optional[str] = None) -> Optional[Mod
|
||||
Parse a mod.info file body. Returns None if no `id=` line found.
|
||||
Lines are `key=value`; keys lowercased; list-fields comma-separated.
|
||||
"""
|
||||
# Strip a leading UTF-8 BOM if present. Some authors save mod.info with
|
||||
# BOM (notepad.exe default on Windows); without this, the first line's
|
||||
# `name=` regex misses because the line starts with U+FEFF instead of
|
||||
# `n`, leaving the mod with an empty display name even though `id=` on
|
||||
# subsequent lines parses fine.
|
||||
text = text.lstrip("")
|
||||
fields: Dict[str, object] = {}
|
||||
for raw in text.splitlines():
|
||||
line = raw.strip()
|
||||
|
||||
Reference in New Issue
Block a user