Skip to content

Conversation

@kwkam
Copy link
Contributor

@kwkam kwkam commented Jul 29, 2018

PR Summary

*System.Management.Automation/engine/CommandCompletion/CompletionCompleters:
Use WildcardPattern::Escape to escape completion text of filename.

*System.Management.Automation/engine/SessionStateContainer:
@Get-ChildItem
Unescape non-literal, non-glob path before existence checking.
This solve the issue where Get-GhildItem does not behave correctly
when -Path contains special characters. For example,

Get-ChildItem -Path './`[dir`]'

will complain with error "Cannot find path ..." while

Get-ChildItem -Path './`[dir`]' -Depth 0

will work fine.

@New-Item
Unescape non-literal path when -Name is not set.
This works around for New-Item treating -Path as literal path while
it can also be globbable. For example, assuming there is "[file]1"
in current directory, and tab completion suggests './`[file`]1'
for the -Path argument, but

New-Item -Path './`[file`]2'

will create a file named "`[file`]2" instead of "[file]2".

*System.Management.Automation/engine/regex:
WildcardPattern::Escape should also escape "`" since
WildcardPattern::Unescape would unescape it,
and the matcher parse it as escape character.

*System.Management.Automation/namespaces/LocationGlobber:
Do not escape CWD when LiteralPath is used. This causes issues when
both -LiteralPath and CWD contains special characters.
Do not pass regex escaped string to WildcardPattern::Get. This fails
tab completion when doing "./path/to/`[f"<TAB>.

*System.Management.Automation/utils/PathUtils:
Unescape non-literal, non-glob path before calling
GetUnresolvedProviderPathFromPSPath since it only accepts literal path.
This solve the issue where some commands depending on that method
will treat -Path as literal unintentionally. For example,

Out-File -Path './`[out`].txt' -Append

will create a new file named "`[out`].txt" instead of writing to "[out].txt".

PR Checklist

kwkam added 2 commits July 29, 2018 12:06
*System.Management.Automation/engine/CommandCompletion/CompletionCompleters:
Use WildcardPattern::Escape to escape completion text of filename.

*System.Management.Automation/engine/SessionStateContainer:
@Get-ChildItem
Unescape non-literal, non-glob path before existence checking.
This solve the issue where Get-GhildItem does not behave correctly
when -Path contains special characters. For example,
> Get-ChildItem -Path './`[dir`]'
will complain with error "Cannot find path ..." while
> Get-ChildItem -Path './`[dir`]' -Depth 0
will work fine.
@New-Item
Unescape non-literal path when -Name is not set.
This works around for New-Item treating -Path as literal path while
it can also be globbable. For example, assuming there is "[file]1"
in current directory, and tab completion suggests './`[file`]1'
for the -Path argument, but
> New-Item -Path './`[file`]2'
will create a file named "`[file`]2" instead of "[file]2".

*System.Management.Automation/engine/regex:
WildcardPattern::Escape should also escape "`" since
WildcardPattern::Unescape would unescape it,
and the matcher parse it as escape character.

*System.Management.Automation/namespaces/LocationGlobber:
Do not escape CWD when LiteralPath is used. This causes issues when
both -LiteralPath and CWD contains special characters.
Do not pass regex escaped string to WildcardPattern::Get. This fails
tab completion when doing "./path/to/`[f"<TAB>.

*System.Management.Automation/utils/PathUtils:
Unescape non-literal, non-glob path before calling
GetUnresolvedProviderPathFromPSPath since it only accepts literal path.
This solve the issue where some commands depending on that method
will treat -Path as literal unintentionally. For example,
> Out-File -Path './`[out`].txt' -Append
will create a new file named "`[out`].txt" instead of writing to "[out].txt".
@kwkam
Copy link
Contributor Author

kwkam commented Jul 30, 2018

Further split into #7403 #7404 #7405 #7406 #7407

@kwkam kwkam closed this Jul 30, 2018
@kwkam kwkam deleted the wc-major branch August 13, 2018 15:06
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.

1 participant