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.
pull/564/head
Srinidhi Kaushik 2018-10-16 20:01:47 +05:30
parent 95c99eb052
commit d17ce325a6
No known key found for this signature in database
GPG Key ID: A37B977BB13301D0
2 changed files with 7 additions and 2 deletions

View File

@ -310,8 +310,8 @@ func stripPathShortcuts(p string) string {
trimmed = strings.TrimPrefix(newPath, "../")
}
// trim leftover ".."
if newPath == ".." {
// trim leftover {".", ".."}
if (newPath == "." || newPath == "..") {
newPath = ""
}

View File

@ -173,6 +173,11 @@ func TestStripPathShortcuts(t *testing.T) {
input: "...foo",
expected: "...foo",
},
{
name: "test root directory",
input: "/",
expected: "",
},
}
for _, test := range tests {