Address Set-Location/Get-Item Issue With ?/* Characters - #12294
Address Set-Location/Get-Item Issue With ?/* Characters#12294Bryan Berns (NoMoreFood) wants to merge 4 commits into
Conversation
- Adjusted behavior of GetCorrectCasedPath() which attempts to search for the file on the file system in order to normalize its case. Since some file systems support wildcard characters in path names; processing needs to be skipped for these. - Added tests to detect this behavior.
Travis Plunk (TravisEz13)
left a comment
There was a problem hiding this comment.
This look good. Thanks.
I've requested a coup of changes in the tests to make sure it doesn't regress things now or in the future.
|
@PowerShell/powershell-committee This is a breaking change. Please review. We made a similar change for matching commands. Where we prefer literal matches over wildcard matches. |
|
Travis Plunk (@TravisEz13) So I can categorize these correctly in the future, can you educate me as to why this would be considered a breaking change? |
|
@PowerShell/powershell-committee agrees that the current behavior is broken where: set-location -literalpath ?must treat |
- Mark backslash test on MacOS / Linux as 'Pending' vice 'Skipped'. - Use Utils.Separators.StarOrQuestion instead of hard-coded constants.
|
I'm not sure your change addressed the committee's concern about the location of the change. |
|
Travis Plunk (@TravisEz13) Sorry, the day job has distracted me from following through on this and one other PR. I honestly thought the "location of the code change" comment was sort of meant to be rhetorical. The bug itself can be scoped to that helper function: In what scenario would I possibly pass a literal, existing directory path to GetCorrectCasedPath() and it would be acceptable to get back a reference to an existing different directory? The function exists solely to normalize case within a path --- it should NEVER be returning a path to a different file. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
- Added failure test for a directory that contains wildcard characters.
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
Is this ready for merge or are we still waiting for reviews? Travis Plunk (@TravisEz13) |
Bryan Berns (NoMoreFood)
left a comment
There was a problem hiding this comment.
I believe I have resolved these.
Here is the direct call: Then, We need to make sure we didn't break any of these calls. |
|
I'll let the Provider working group review from here. |
|
The GetCorrectCasedPath() is not in right place. This would only have to be used in Formatting System and completors. |
|
Travis Plunk (@TravisEz13) All of the non-file system paths you reference end up calling a base class version or provider-specific version of NormalizePath() so this change luckily does not affect them. Ilya (@iSazonov) I think that might be splitting hairs to some degree. When somebody does a Set-Location to a specific path, do you want the resultant path at the prompt to be case-accurate or not? I think it might be hard to address all the "what if" sort of cases. Regardless, this PR was authored to address the "bug" within GetCorrectCasedPath() itself so I was hoping not to boil the ocean to get this committed. :-) |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PR Summary
PR Context
This corrects the behavior where Set-Location fails to change directory or changes to an entirely different child directory when the target directory contains characters such as '*'. Similarly, Get-Item also returns errant information.
Resolves: #12299
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.