-
Notifications
You must be signed in to change notification settings - Fork 131
TSCBasic: protect against an invalid API usage #325
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
Conversation
@swift-ci please test |
@swift-ci please test macOS platform |
f726748
to
5d31e72
Compare
@swift-ci please test |
5d31e72
to
01849f8
Compare
@swift-ci please test |
@swift-ci please test macOS platform |
@swift-ci please test |
1 similar comment
@swift-ci please test |
`filePathRepresentation` may not be invoked on an empty string. This protects against that case which does occur during the SPM test suite execution.
b8025fc
to
561bd3d
Compare
@swift-ci please test |
this does a bit more than just the empty string case, can you elaborate on what is going on here? cc @abertelrud |
1 similar comment
this does a bit more than just the empty string case, can you elaborate on what is going on here? cc @abertelrud |
@@ -254,7 +259,18 @@ public struct RelativePath: Hashable { | |||
/// normalization or canonicalization. This will construct a path without | |||
/// an anchor and thus may be invalid. | |||
fileprivate init(unsafeUncheckedPath string: String) { | |||
self.init(PathImpl(string: string)) | |||
if string.isEmpty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the case need to be a guard and then return a ~const empty representation?
@@ -254,7 +259,18 @@ public struct RelativePath: Hashable { | |||
/// normalization or canonicalization. This will construct a path without | |||
/// an anchor and thus may be invalid. | |||
fileprivate init(unsafeUncheckedPath string: String) { | |||
self.init(PathImpl(string: string)) | |||
if string.isEmpty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the case need to be a guard and then return a ~const empty representation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change that of course, but that doesn't help the macOS case. It would be purely a syntactic change and should be equivalent to this.
@swift-ci please test macOS platform |
@compnerd this does a bit more than just the empty string case, can you elaborate on what is going on here / why all the thing manipulation is needed? |
1 similar comment
@compnerd this does a bit more than just the empty string case, can you elaborate on what is going on here / why all the thing manipulation is needed? |
@tomerd I don't follow, its doing nothing at all ...
If it is not empty, we normalize the string and return that because the path operations should be performed on the normalized form (otherwise we need to go in at each point where an API is called and re-normalize the path before each call, which is extremely expensive as strings must be re-encoded to UTF16, have the conversion, re-encoded to UTF8, manipulated and then re-encoded to UTF16 to perform the operation). |
Hmm, wait, do you mean the |
iiuc the non-empty code path is now:
that is quite different from that the code used to be, and the motivation for this change (why do we need to use fileSystemRepresentation? what problem is it solving) is not explained as the motivation for this PR |
Ah, I see. The difference in the ObjC runtime is because As to why the call to |
can you give some concrete examples of what this does exactly / what concrete problem it solves. I am a bit worried about replying on fileSystemRepresentation. @milseman @abertelrud can you chime in here too? |
I suppose I can try to work through and find the test cases it fixes in SPM's test suite. It fixed a few of the last failures. It literally converts |
Sorry, I'm not familiar with what this is. This doesn't look to be using |
Right, this is still using the path utilities from tools-support-core, not the swift-system FilePath. |
@swift-ci please test Windows platform |
@compnerd iirc #369 and swiftlang/swift-package-manager#5910 are designed to avoid some of these issues, we should prioritize getting them over the finish lines so we need less workarounds like this |
@tomerd are you okay with merging this for now? I'm going to likely take a pause on some of the SPM work and see if we can get the two mentioned changes merged as that is going to just be generally easier to make progress with. |
@compnerd are you asking if we can merge #369 and swiftlang/swift-package-manager#5910? I am happy to merge them if you can confirm they are not breaking anything for windows and helping with some of the windows path issues |
@tomerd I meant merging this change so that I can have a little bit of breathing room to work through those two changes :) |
I am not comfortable with this change for all platforms. if you can do something more minimal for windows we can consider that |
@tomerd okay, can you please at least get the patch pair that you have building on Windows? I should be able to put it through its paces on Windows once you have the patches complete. Can we get that done early today so that I can test it? Alternatively, can we merge this temporarily so that we can work through the issues in the much larger refactoring? |
@compnerd just kicked off the windows build - this is done via cross repo testing in swiftlang/swift-package-manager#5910. may need your help if there are any windows specific errors |
I believe that this can be closed off now that we have the other change merged. |
filePathRepresentation
may not be invoked on an empty string. Thisprotects against that case which does occur during the SPM test suite
execution.