Skip to content

Fix crash when assigning non-ASCII file extensions - #405

Open
crleonard wants to merge 2 commits into
apple:mainfrom
crleonard:fix-unicode-file-extension
Open

crleonard wants to merge 2 commits into
apple:mainfrom
crleonard:fix-unicode-file-extension

Conversation

@crleonard

Copy link
Copy Markdown

Assigning a non-ASCII extension, such as path.extension = "é", crashes with “Code point value does not fit into ASCII”.

Replace the ASCII-only scalar conversion in _makeExtension(_:) with the existing SystemString initializer, which uses the platform’s Unicode encoding. The assignment now produces the same path as constructing FilePath("file.é") directly.

Fixes #404

Tests and documentation

  • Add regression coverage for accented characters, emoji, combining marks, and mixed ASCII/Unicode extensions.
  • Cover hidden and compound filenames, extension replacement and removal, and unchanged special paths.
  • Clarify Unicode support in the DocC comment with an example.

Validation

  • Confirmed the original regression test crashes before the fix.
  • Full macOS suite passes: 73 XCTest tests and 8 Swift Testing tests.
  • Standalone Unicode reproducer passes against the optimized library.
  • Linux and Windows runtime tests have not been run locally.

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.

FilePath.extension setter crashes with non-ASCII characters

1 participant