mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 04:27:54 +00:00
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:
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
Block a user