mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 09:52:20 +08:00
Add path validation in Resolver.ResolvePath
Add ErrNoComponents in ParsePath validation & remove redundant path validation. Any lines using core.Resolve & Resolver.ResolvePath will have their path validated. License: MIT Signed-off-by: rht <rhtbot@gmail.com>
This commit is contained in:
@ -65,6 +65,11 @@ func SplitAbsPath(fpath Path) (mh.Multihash, []string, error) {
|
||||
// ResolvePath fetches the node for given path. It returns the last item
|
||||
// returned by ResolvePathComponents.
|
||||
func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (*merkledag.Node, error) {
|
||||
// validate path
|
||||
if err := fpath.IsValid(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nodes, err := s.ResolvePathComponents(ctx, fpath)
|
||||
if err != nil || nodes == nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user