Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/kubo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 988b158dc7dc
Choose a base ref
...
head repository: ipfs/kubo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 78defff35d77
Choose a head ref
  • 4 commits
  • 2 files changed
  • 2 contributors

Commits on May 21, 2015

  1. Daemon panics if no path is given

    If no path after `/ipfs/` or `/ipns/` is given, then the daemon will
    panic with a slice bounds out of range error. This checks to see if we
    have anything after `ipfs` or `ipns`.
    travisperson committed May 21, 2015
    Copy the full SHA
    55c74f1 View commit details
  2. Replaced old logic to check for valid path

    Added the original logic to check for a invalid path and a simple test.
    travisperson committed May 21, 2015
    Copy the full SHA
    c8cde25 View commit details
  3. Fixed tests to actually test for the error we are seeking

    Cleaned the tests, and actually test for the error.
    travisperson committed May 21, 2015
    Copy the full SHA
    a439f9a View commit details

Commits on May 22, 2015

  1. Merge pull request #1265 from travisperson/bug/panic-on-empty-path

    Daemon panics if no path is given
    jbenet committed May 22, 2015
    Copy the full SHA
    78defff View commit details
Showing with 27 additions and 0 deletions.
  1. +6 −0 core/pathresolver.go
  2. +21 −0 core/pathresolver_test.go
6 changes: 6 additions & 0 deletions core/pathresolver.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package core
import (
"errors"
"strings"
"fmt"

context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"

@@ -29,6 +30,11 @@ func Resolve(ctx context.Context, n *IpfsNode, p path.Path) (*merkledag.Node, er
}

seg := p.Segments()

if len(seg) < 2 || seg[1] == "" { // just "/<protocol/>" without further segments
return nil, fmt.Errorf("invalid path: %s", string(p))
}

extensions := seg[2:]
resolvable, err := path.FromSegments("/", seg[0], seg[1])
if err != nil {
21 changes: 21 additions & 0 deletions core/pathresolver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package core

import (
"testing"

path "github.com/ipfs/go-ipfs/path"
"strings"
)

func TestResolveInvalidPath(t *testing.T) {
n, err := NewMockNode()
if n == nil || err != nil {
t.Fatal("Should have constructed.", err)
}

_, err = Resolve(n.Context(), n, path.Path("/ipfs/"))
if !strings.HasPrefix(err.Error(), "invalid path") {
t.Fatal("Should get invalid path.", err)
}

}