Skip to content

Darwin SearchPaths without expanding tilde produce non-tilde-based paths #1069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jmschonfeld
Copy link
Contributor

The String, ObjC-based search path enumeration calls the Swift implementation which produces a URL and then converts each URL back to a String path. This process is actually making paths absolute which is fine for Swift use cases, but the ObjC API has an option to prevent expansion of the tilde directory. By passing those unexpanded paths through URL, we end up with paths like /Users/USER/Library which are incorrect because the tilde is expanded.

To avoid these behaviors and maintain support for the "legacy" ObjC behavior for string paths, I shuffled the functions around just a bit so that the implementation creates Strings instead of URLs and only converts to URL for the Swift API. This also allows us to test the String results directly in our unit tests to add a test that validates this behavior even in non-FOUNDATION_FRAMEWORK builds.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit db10408 into swiftlang:main Dec 4, 2024
3 checks passed
@jmschonfeld jmschonfeld deleted the fm-darwin-searchpaths-tilde branch December 4, 2024 20:52
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.

3 participants