Fix local copy path for `kubectl cp'.
Adds an extra check condition for "." in stripPathShortcuts so that an empty string is returned, and the correct prefix index is used untarAll when generating path names. Resolves: #69804.
This commit is contained in:
@@ -310,8 +310,8 @@ func stripPathShortcuts(p string) string {
|
||||
trimmed = strings.TrimPrefix(newPath, "../")
|
||||
}
|
||||
|
||||
// trim leftover ".."
|
||||
if newPath == ".." {
|
||||
// trim leftover {".", ".."}
|
||||
if (newPath == "." || newPath == "..") {
|
||||
newPath = ""
|
||||
}
|
||||
|
||||
|
@@ -173,6 +173,11 @@ func TestStripPathShortcuts(t *testing.T) {
|
||||
input: "...foo",
|
||||
expected: "...foo",
|
||||
},
|
||||
{
|
||||
name: "test root directory",
|
||||
input: "/",
|
||||
expected: "",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Reference in New Issue
Block a user