Conversation
|
|
||
| internal static readonly char[] InvalidPathChars = | ||
| { | ||
| '\"', '<', '>', '|', '\0', |
There was a problem hiding this comment.
These characters can be used in file paths passed to Win32 functions like CreateFile?
There was a problem hiding this comment.
FindFirstFile is where the wildcards come into play- and is why we have the current ones (*, ?) broken out. We check all characters in GetFullPath.
What does or doesn't work with CreateFile is device/file system dependent. You can use most of these with pipes, for example. Null and backslash are the most "reserved" of the lot as the null terminates string logic and the backslash is the separator the object manager uses.
There was a problem hiding this comment.
If this is changed, then I believe the function I recently modified (HasIllegalCharacters) needs to be changed as well to eliminate checks for these characters.
|
Won't this affect the behavior of some FileSystem functions? They use PathInternal.InvalidPathChars. I don't think we have tests in place to see what happens when they pass a (potentially valid) path that contains one of these unusual search characters? I'm particularly interested in whether a search pattern with one of these is allowed and passed to the win32 functions or if it throws an error before it gets the chance. |
|
@ianhays Only the ones that don't do the full check (which includes the wildcards). That behavior is by design so you can actually utilize wildcards where it makes sense. Path.GetFullPath checks all characters. |
| internal unsafe static bool HasWildCardCharacters(string path) | ||
| { | ||
| // Question mark is part of extended syntax so we have to skip if we're extended | ||
| int startIndex = PathInternal.IsExtended(path) ? ExtendedPathPrefix.Length : 0; |
There was a problem hiding this comment.
startIndex isn't being used anymore in the new code...
There was a problem hiding this comment.
Whoops- thanks! I'll add some tests.
|
Test Innerloop CentOS7.1 Debug Build and Test please |
|
@ianhays, @stephentoub Are you ok with this? |
|
|
|
Are the same wildcard changes being made to desktop? |
|
@stephentoub, that's the intent |
|
@JeremyKuhne, what's the status of this PR? |
| internal static readonly char[] InvalidPathChars = | ||
| { | ||
| '\"', '<', '>', '|', '\0', | ||
| '|', '\0', |
There was a problem hiding this comment.
Nit: indentation is off here
422f54c to
7e7f67f
Compare
|
@stephentoub I've updated the PR, are you ok with this change? |
| internal static char[] GetInvalidPathChars() => new char[] | ||
| { | ||
| '\"', '<', '>', '|', '\0', | ||
| '|', '\0', |
There was a problem hiding this comment.
Nit: extra space before the first single quote
|
@ericstj, @weshaggard, thoughts on the wildcard change? |
7e7f67f to
3c47374
Compare
|
@weshaggard I thought a testproject pkgproj reference was supposed to pull in the local bits? I can't seem to get this to pull in the right binary any more- tried a direct reference to the src csproj as well but the Random and StringComparer tests can't compile. |
I don't have much context on the actual change or the risk it has but I do worry a little about the compat on desktop. @JeremyKuhne what do you think the compat risk for this change will be?
A pkgproj reference will pull in the most appropriate asset it might be the local built or not it really depends on what the test project is building against. Does the TargetGroup for the test project match what you want it to pull from the source project? |
| @@ -210,8 +195,6 @@ internal static bool HasIllegalCharacters(string path) | |||
| switch (c) | |||
| { | |||
| case '"': | |||
There was a problem hiding this comment.
Is it intentional '"' is still kept here when it it removed from the array?
There was a problem hiding this comment.
(And assuming it's not, seems like we're missing a test.)
There was a problem hiding this comment.
Doh. Thanks- trying to code when sick- I did have a test and it is failing. 😷 I'm going to move the one remaining case up to the other if block.
|
I imagine this will have the effect of changing an ArgumentException to an IOException in some cases, which would make it a breaking change on Desktop that likely requires a quirk. |
And...
I think the risk is pretty low. Most places will still kick the path- the reason they're (bad and wildcard chars) separated is to allow enumerating. That said, I intend to put the change behind the existing normalization quirk on desktop. |
- Simplify the path length check to match desktop - Tweak IsPartiallyQualified to match desktop - Update wildcards to actually match what Windows supports
3c47374 to
50cb4c1
Compare
I'm a bit under the weather- it was working as expected and failing as expected. Thanks. |
|
@ericstj, @stephentoub, @weshaggard, @jamesqo Updated and green. |
|
As long as we're ok with the behavior change, LGTM. |
Windows path tweaks Commit migrated from dotnet/corefx@12e18e2
It came as a surprise to me, but yes, there are more wildcard characters in Windows than "*" and "?".
https://msdn.microsoft.com/en-us/library/ff469270.aspx
You can use these other wildcards from the CMD prompt as long as you quote and escape the quote if you use it. (It is a FindFirstFile thing)
@ianhays, @ericstj, @stephentoub