mirror of https://github.com/k3s-io/k3s
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
parent
95c99eb052
commit
d17ce325a6
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue