MCPcopy Index your code
hub / github.com/cli/cli / isSubpathOf

Method isSubpathOf

internal/safepaths/absolute.go:59–65  ·  view source on GitHub ↗
(dir Absolute)

Source from the content-addressed store, hash-verified

57}
58
59func (a Absolute) isSubpathOf(dir Absolute) (bool, error) {
60 relativePath, err := filepath.Rel(dir.path, a.path)
61 if err != nil {
62 return false, err
63 }
64 return !strings.HasPrefix(relativePath, ".."), nil
65}
66
67type PathTraversalError struct {
68 Base Absolute

Callers 1

JoinMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected