Unverified Commit c44191e0 authored by Whyrusleeping's avatar Whyrusleeping Committed by GitHub

Merge pull request #4743 from schomatis/fix/unixfs/dagarchive-path

unixfs: clean path in DagArchive
parents b8e7b632 f710b31f
...@@ -104,6 +104,14 @@ test_get_cmd() { ...@@ -104,6 +104,14 @@ test_get_cmd() {
rm -r "$HASH2" rm -r "$HASH2"
' '
# Test issue #4720: problems when path contains a trailing slash.
test_expect_success "ipfs get with slash (directory)" '
ipfs get "$HASH2/" &&
test_cmp dir/a "$HASH2"/a &&
test_cmp dir/b/c "$HASH2"/b/c &&
rm -r "$HASH2"
'
test_expect_success "ipfs get -a -C succeeds (directory)" ' test_expect_success "ipfs get -a -C succeeds (directory)" '
ipfs get "$HASH2" -a -C >actual ipfs get "$HASH2" -a -C >actual
' '
......
...@@ -33,7 +33,8 @@ func (i *identityWriteCloser) Close() error { ...@@ -33,7 +33,8 @@ func (i *identityWriteCloser) Close() error {
// DagArchive is equivalent to `ipfs getdag $hash | maybe_tar | maybe_gzip` // DagArchive is equivalent to `ipfs getdag $hash | maybe_tar | maybe_gzip`
func DagArchive(ctx context.Context, nd ipld.Node, name string, dag ipld.DAGService, archive bool, compression int) (io.Reader, error) { func DagArchive(ctx context.Context, nd ipld.Node, name string, dag ipld.DAGService, archive bool, compression int) (io.Reader, error) {
_, filename := path.Split(name) cleaned := path.Clean(name)
_, filename := path.Split(cleaned)
// need to connect a writer to a reader // need to connect a writer to a reader
piper, pipew := io.Pipe() piper, pipew := io.Pipe()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment