mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
powershell.ps1: Validate Windows paths (#26488)
During the writing of Windows path integration tests we discovered that incorrect paths (including escape sequences) cause very cryptic error messages. This fix ensures that invalid paths cause a proper error message. We also had to fix the following modules: - win_shortcut: `src` can be a URL
This commit is contained in:
parent
c0fc79647a
commit
05e5698472
2 changed files with 5 additions and 1 deletions
|
@ -205,6 +205,10 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail
|
|||
if ($type -eq "path") {
|
||||
# Expand environment variables on path-type
|
||||
$value = Expand-Environment($value)
|
||||
# Test if a valid path is provided
|
||||
if (-not (Test-Path -IsValid $value)) {
|
||||
Fail-Json -obj $resultobj -message "Get-AnsibleParam: Parameter '$name' has an invalid path '$value' specified."
|
||||
}
|
||||
} elseif ($type -eq "str") {
|
||||
# Convert str types to real Powershell strings
|
||||
$value = $value.ToString()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue