Skip to content

Recheck reserved filenames after trimming Windows edge spaces - #81

Open
boyfeiyu wants to merge 1 commit into
thombashi:masterfrom
boyfeiyu:fix/BOYF-34-reserved-after-trim
Open

boyfeiyu wants to merge 1 commit into
thombashi:masterfrom
boyfeiyu:fix/BOYF-34-reserved-after-trim

Conversation

@boyfeiyu

Copy link
Copy Markdown

Fixes #70.

On Windows and universal platforms, stripping edge spaces or trailing periods can expose a reserved filename: sanitize_filename(" AUX") currently returns AUX. Recheck reserved names after that cleanup and use the existing reserved-name handler for filename and filepath components.

Keep the initial validation so custom names containing edge spaces, such as additional_reserved_names=[" CUSTOM"], still match and invoke their handler. Earlier fixes in #72, #73 and #74 were closed without merging; this replacement covers the compatibility case raised on #74 while retaining the existing handler behavior.

Tests cover exposed reserved names, extensions, str/Path inputs, path components, custom names with edge spaces, handler behavior and Linux controls. API docstrings describe the matching order.

Validation on macOS arm64 / CPython 3.9.6:

  • Full suite: 4222 passed, 17 skipped; 110 additional review scenarios passed.
  • Type, formatting, spelling, docs, package build and metadata checks passed.
  • Ruff lint has existing failures: 129 diagnostics on the base, 128 here, with no new diagnostics.

The cross-platform interpreter matrix has not been run locally.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I exercised the Windows and universal cases where trimming exposes reserved names, including custom names that contain edge spaces. The sanitizer now applies the reserved-name handler after that trim while retaining the first validation for custom names; the focused filename tests pass (28 passed). The documentation also states when the second check occurs. This looks good to me.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Sanitize functions does not detect reserved names after stripping leading spaces

2 participants