Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
dca6912c
Unverified
Commit
dca6912c
authored
May 31, 2018
by
juanvallejo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove extra "../" when copying from pod to local
parent
8ad67d34
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
cp.go
pkg/kubectl/cmd/cp.go
+13
-0
No files found.
pkg/kubectl/cmd/cp.go
View file @
dca6912c
...
@@ -287,9 +287,22 @@ func (o *CopyOptions) copyFromPod(src, dest fileSpec) error {
...
@@ -287,9 +287,22 @@ func (o *CopyOptions) copyFromPod(src, dest fileSpec) error {
}()
}()
prefix
:=
getPrefix
(
src
.
File
)
prefix
:=
getPrefix
(
src
.
File
)
prefix
=
path
.
Clean
(
prefix
)
prefix
=
path
.
Clean
(
prefix
)
// remove extraneous path shortcuts - these could occur if a path contained extra "../"
// and attempted to navigate beyond "/" in a remote filesystem
prefix
=
stripPathShortcuts
(
prefix
)
return
untarAll
(
reader
,
dest
.
File
,
prefix
)
return
untarAll
(
reader
,
dest
.
File
,
prefix
)
}
}
// stripPathShortcuts removes any leading or trailing "../" from a given path
func
stripPathShortcuts
(
p
string
)
string
{
newPath
:=
path
.
Clean
(
p
)
if
len
(
newPath
)
>
0
&&
string
(
newPath
[
0
])
==
"/"
{
return
newPath
[
1
:
]
}
return
newPath
}
func
makeTar
(
srcPath
,
destPath
string
,
writer
io
.
Writer
)
error
{
func
makeTar
(
srcPath
,
destPath
string
,
writer
io
.
Writer
)
error
{
// TODO: use compression here?
// TODO: use compression here?
tarWriter
:=
tar
.
NewWriter
(
writer
)
tarWriter
:=
tar
.
NewWriter
(
writer
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment