MCPcopy Create free account
hub / github.com/cli/cli / checkTraversal

Function checkTraversal

internal/safeurl/safeurl.go:75–82  ·  view source on GitHub ↗

checkTraversal returns an error if any component is exactly "..". Such a component survives percent-encoding as a real path segment and would traverse the URL path. A single "." is left alone because it does not traverse and is a legitimate value in some paths.

(components []string)

Source from the content-addressed store, hash-verified

73// A single "." is left alone because it does not traverse and is a legitimate value
74// in some paths.
75func checkTraversal(components []string) error {
76 for _, c := range components {
77 if c == ".." {
78 return fmt.Errorf("path component %q would traverse the URL path", c)
79 }
80 }
81 return nil
82}
83
84func (u *MutableSafeURL) sealed() {}
85

Callers 2

JoinPathFunction · 0.85
JoinPathWithHostPrefixFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected