@cryptotaxi247 / kubo / commits / 37f33812a

error on resolving non-terminal paths

This isn't the *correct* fix but it (mostly) restores the previous behavior. Note 1: It *also* fixes resolution of `/ipld` paths by avoiding `path.FromCid`. Note 2: This does not preserve the error. That was a DagCBOR specific error that has nothing to do with the issue. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Oct 30, 2018 at 12:34 UTC 37f33812ae61e0d5f2cdf3f273493922e01f324c
2 files changed +13 -2
core/commands/resolve.go
+4 -2
@@ -135,9 +135,11 @@ Resolve the value of an IPFS DAG path:
135 return err
136 }
137
138 - c := rp.Cid()
138 + if rp.Remainder() != "" {
139 + return fmt.Errorf("path does not end on a dag-node boundary")
140 + }
141
140 - return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.FromCid(c)})
142 + return cmds.EmitOnce(res, &ncmd.ResolvedPath{Path: path.Path("/" + rp.Namespace() + "/" + rp.Cid().String())})
143 },
144 Encoders: cmds.EncoderMap{
145 cmds.Text: cmds.MakeEncoder(func(req *cmds.Request, w io.Writer, v interface{}) error {
test/sharness/t0160-resolve.sh
+9
@@ -14,6 +14,10 @@ test_expect_success "resolve: prepare files" '
14 c_hash=$(ipfs add -q -r a/b/c | tail -n1)
15 '
16
17 +test_expect_success "resolve: prepare dag" '
18 + dag_hash=$(ipfs dag put <<<"{\"a\": {\"b\": {\"c\": \"asdfasdfasdf\"}}}")
19 +'
20 +
21 test_resolve_setup_name() {
22 ref=$1
23
@@ -92,6 +96,11 @@ test_resolve_cmd_fail() {
96 test_resolve "/ipfs/$a_hash/b" "/ipfs/$b_hash"
97 test_resolve "/ipfs/$a_hash/b/c" "/ipfs/$c_hash"
98 test_resolve "/ipfs/$b_hash/c" "/ipfs/$c_hash"
99 + test_resolve "/ipld/$dag_hash" "/ipld/$dag_hash"
100 +
101 + test_resolve_fail "/ipld/$dag_hash/a/b/c" "/ipld/$dag_hash/a/b/c"
102 + test_resolve_fail "/ipld/$dag_hash/a/b" "/ipld/$dag_hash/a/b"
103 + test_resolve_fail "/ipld/$dag_hash/a" "/ipld/$dag_hash/a"
104
105 test_resolve_setup_name_fail "/ipfs/$a_hash"
106 test_resolve_fail "/ipns/$id_hash" "/ipfs/$a_hash"