fix(core): detect case-insensitive overlap for nonexistent cache/data dirs on Windows #103

Closed
Djei365 wants to merge 0 commits from upstream-pr/103 into main
Djei365 commented 2026-11-25 22:59:56 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by Djei365 on 2026-11-25T22:59:56Z.


Closes #55

Problem

The overlap protection introduced in #42 can miss equivalent Windows paths when directory components do not exist yet and differ only in letter case.

For example, on a case-insensitive NTFS directory:

  • cache_dir = cache
  • data_dir = CACHE/saves

These paths may overlap once created, potentially exposing persistent data to cache cleanup.

Solution

  • Detect case-insensitive overlap between nonexistent path components on Windows.
  • Query case sensitivity from the nearest existing ancestor.
  • Use Windows ordinal Unicode comparison.
  • Preserve case-sensitive directories, unrelated sibling paths, inverse nesting, and non-Windows behavior.
  • Reject indeterminate case-sensitivity queries rather than silently assuming case-insensitivity.
  • Avoid creating directories during configuration validation.
  • Introduce no new dependencies.

The existing ensure_outside_repo policy remains unchanged.

Validation

  • 21 unit tests passed.
  • Case-sensitive NTFS control test passed separately.
  • ASCII and Unicode regression tests passed.
  • Multiple nonexistent path components tested.
  • Interior NUL regression tested.
  • Rustfmt passed.
  • Clippy passed with -D warnings.
  • Git diff checks passed.

All local checks were repeated successfully after rebasing onto upstream main.

Limitations

Local validation was performed on Windows with NTFS. Non-Windows execution, alternative filesystems, and older Windows versions were not tested locally.

Case-sensitivity inference assumes normal directory inheritance and cannot anticipate future filesystem configuration changes.

Acknowledgment

This change builds upon the overlap protection introduced by @LouisRiverstone in #42.

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:5500641131 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VitoriaBr2.0/pull/103). Originally posted by [Djei365](https://github.com/Djei365) on 2026-11-25T22:59:56Z. --- Closes #55 ## Problem The overlap protection introduced in #42 can miss equivalent Windows paths when directory components do not exist yet and differ only in letter case. For example, on a case-insensitive NTFS directory: - `cache_dir = cache` - `data_dir = CACHE/saves` These paths may overlap once created, potentially exposing persistent data to cache cleanup. ## Solution - Detect case-insensitive overlap between nonexistent path components on Windows. - Query case sensitivity from the nearest existing ancestor. - Use Windows ordinal Unicode comparison. - Preserve case-sensitive directories, unrelated sibling paths, inverse nesting, and non-Windows behavior. - Reject indeterminate case-sensitivity queries rather than silently assuming case-insensitivity. - Avoid creating directories during configuration validation. - Introduce no new dependencies. The existing `ensure_outside_repo` policy remains unchanged. ## Validation - [x] 21 unit tests passed. - [x] Case-sensitive NTFS control test passed separately. - [x] ASCII and Unicode regression tests passed. - [x] Multiple nonexistent path components tested. - [x] Interior NUL regression tested. - [x] Rustfmt passed. - [x] Clippy passed with `-D warnings`. - [x] Git diff checks passed. All local checks were repeated successfully after rebasing onto upstream main. ## Limitations Local validation was performed on Windows with NTFS. Non-Windows execution, alternative filesystems, and older Windows versions were not tested locally. Case-sensitivity inference assumes normal directory inheritance and cannot anticipate future filesystem configuration changes. ## Acknowledgment This change builds upon the overlap protection introduced by @LouisRiverstone in #42.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
uiliannn/VItoriaBr!103
No description provided.