mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #18736 from Luap99/completion-panic
completion: fix panic in simplePathJoinUnix()
This commit is contained in:
@ -362,6 +362,11 @@ func getPathCompletion(root string, toComplete string) ([]string, cobra.ShellCom
|
||||
// We cannot use path.Join() for the completions logic because this one always calls Clean() on
|
||||
// the path which changes it from the input.
|
||||
func simplePathJoinUnix(p1, p2 string) string {
|
||||
if len(p1) == 0 {
|
||||
// Special case if p1 is not set just return p2 as is
|
||||
// and do not add a slash as the input didn't contain one either.
|
||||
return p2
|
||||
}
|
||||
if p1[len(p1)-1] == '/' {
|
||||
return p1 + p2
|
||||
}
|
||||
|
@ -353,6 +353,11 @@ function _check_no_suggestions() {
|
||||
run_completion $cmd $IMAGE "/etc/os-"
|
||||
assert "$output" =~ ".*^/etc/os-release\$.*" "/etc files suggested (cmd: podman $cmd /etc/os-)"
|
||||
|
||||
# regression check for https://bugzilla.redhat.com/show_bug.cgi?id=2209809
|
||||
# check for relative directory without slash in path.
|
||||
run_completion $cmd $IMAGE "e"
|
||||
assert "$output" =~ ".*^etc/\$.*" "etc dir suggested (cmd: podman $cmd e)"
|
||||
|
||||
# check completion with relative path components
|
||||
# It is important the we will still use the image root and not escape to the host
|
||||
run_completion $cmd $IMAGE "../../"
|
||||
|
Reference in New Issue
Block a user