From a0bb8b47dc5c334eb14b14a92beda118d25b5784 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 26 Oct 2026 09:03:33 +0100 Subject: [PATCH] Verify exact mod membership names after case-only renames (by Codex) --- src/modern/ui/mod_library.cpp | 9 +++++++++ tests/modern_mods_ui_tests.cpp | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/modern/ui/mod_library.cpp b/src/modern/ui/mod_library.cpp index 9984458..c328329 100644 --- a/src/modern/ui/mod_library.cpp +++ b/src/modern/ui/mod_library.cpp @@ -246,6 +246,15 @@ UiModEntry owned(const fs::path &root, const UiModEntry &expected, bool require_ if (expected.id != expected.name || expected.path != root / "mods" / editor::path(expected.id)) throw editor::Error("Die Mod gehört nicht zu dieser Bibliothek."); member_name(expected.id); + // Library IDs use the spelling actually enumerated on disk, even when the + // host filesystem resolves an obsolete differently-cased path to it. + bool exact_member = false; + for (const auto &file : fs::directory_iterator(root / "mods")) + if (editor::utf8(file.path().filename()) == expected.id) { + exact_member = true; + break; + } + if (!exact_member) throw editor::Error("Diese Mod-ID wurde inzwischen geändert. Bitte erneut auswählen."); if (fs::is_symlink(fs::symlink_status(expected.path)) || !fs::is_directory(expected.path)) throw editor::Error("Unsicheres oder fehlendes Mod-Verzeichnis."); const auto actual = entry(root, expected.id); diff --git a/tests/modern_mods_ui_tests.cpp b/tests/modern_mods_ui_tests.cpp index 47c6bc6..816ff31 100644 --- a/tests/modern_mods_ui_tests.cpp +++ b/tests/modern_mods_ui_tests.cpp @@ -261,7 +261,12 @@ void lifecycle() { selected = library.snapshot(); const auto renamed = library.rename(first, "ÖFFNUNG", selected.selection_token); require(renamed.valid() && library.snapshot().active == renamed.id && fs::exists(renamed.path / "content.obw"), "Case-only rename lost active selection"); + const auto before_case_alias = tree(portable); + rejected([&] { library.activate(first, library.snapshot().selection_token); }, "Obsolete casing alias activated a renamed member"); + rejected([&] { library.rename(first, "Alias rename", library.snapshot().selection_token); }, "Obsolete casing alias renamed a current member"); rejected([&] { library.remove(first, library.snapshot().selection_token); }, "Old membership token survived rename"); + require(tree(portable) == before_case_alias && library.snapshot().active == renamed.id, + "Rejected old casing aliases changed files or persisted active identity"); const auto foreign = UiModLibrary(fixture.root / "other").commit(library.inspect(source), "Foreign"); const auto stable = tree(portable); rejected([&] { library.remove(foreign, library.snapshot().selection_token); }, "Foreign library membership accepted");