rpf9dump: harden Util.Safe for cross-platform and Windows filenames #2876
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2876
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/rpf9dump-util-safe-names"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: RPF9DUMP-UTIL-SAFE-WINDOWS-NAMES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7312115654)
What and why
Hardens
Util.Safe(string s)intools/rpf9dump/Util.csagainst three filename edge cases when exporting archives/textures:Path.GetInvalidFileNameChars()and control characters were replaced with'_'. On Linux/macOS that set only includes'\0'and'/', leaving<>:"/\|?*unsanitized across hosts.Util.Safenow sanitizes<>:"/\|?*uniformly everywhere..Trim(' ', '.')ran only before[..Math.Min(120, v.Length)], so names like"a" * 119 + ".foo"or"a" + "." * 130 + "b"ended with a trailing.or' 'after truncation (rejected/stripped on Windows).Util.Safenow trims trailing spaces/dots after truncation as well (returning"x"if empty).'.'(trimmed of trailing spaces) isCON,PRN,AUX,NUL,COM1..COM9, orLPT1..LPT9(case-insensitive) are prefixed with'_'and bounded to 120 chars without trailing dots/spaces.Tested
Verified locally (Windows 11, .NET SDK 8.0.401, Python 3.14, no game data):
dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Releasefailed ontrailing dot after 120-char truncation.dotnet build tools/rpf9dump/rpf9dump.csproj -c Release: 0 warnings, 0 errorsdotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release: all 7 test groups passed (Util.Safe filename tests passed.)python -I tests/test_rpf9dump_exit_codes.py(with builtRPF9DUMP_DLL): 10 passedpython -I scripts/check_no_game_data.py&git diff --check: cleanGPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)Merging (added to the merge queue). Head f2357faa5 merges cleanly with main c4ca57615. Claim: RPF9DUMP-UTIL-SAFE-WINDOWS-NAMES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7312115654). Red/green: KelboLive review on this head (sanitising and reserved names checked case by case); tool-only change. I ran: #2858, #2882, #2788, #2876 and #2884 merged together onto main c4ca57615: cargo tests leonida-shader 420 passed / 0 failed, leonida-loader 85/0, leonida-gpu 644/0. In-game run: RTX 4070 Laptop 8 GB, NVIDIA 621.40, -SeriesS -NoDlss -NoFrameGen, a cold start to the world (135 s) then a 330 s warm walking run: median 35.4 ms (28.2 fps), private memory max 24.4 GB, 0 device lost. CI: green on head and main; the queue runs the full CI on the group before merging. AI-assisted: Claude Code (oreofr-agent), merge approved in writing by OreoFR.