Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unixfs: clean path in DagArchive #4743

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/sharness/t0090-get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ test_get_cmd() {
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)" '
ipfs get "$HASH2" -a -C >actual
'
Expand Down
3 changes: 2 additions & 1 deletion unixfs/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func (i *identityWriteCloser) Close() error {
// 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) {

_, filename := path.Split(name)
cleaned := path.Clean(name)
_, filename := path.Split(cleaned)

// need to connect a writer to a reader
piper, pipew := io.Pipe()
Expand Down