MCPcopy Create free account
hub / github.com/containerd/nerdctl / ValidatePathComponent

Function ValidatePathComponent

pkg/internal/filesystem/path.go:32–47  ·  view source on GitHub ↗

ValidatePathComponent will enforce os specific filename restrictions on a single path component.

(pathComponent string)

Source from the content-addressed store, hash-verified

30
31// ValidatePathComponent will enforce os specific filename restrictions on a single path component.
32func ValidatePathComponent(pathComponent string) error {
33 // https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits
34 if len(pathComponent) > pathComponentMaxLength {
35 return errors.Join(ErrInvalidPath, errInvalidPathTooLong)
36 }
37
38 if strings.TrimSpace(pathComponent) == "" {
39 return errors.Join(ErrInvalidPath, errInvalidPathEmpty)
40 }
41
42 if err := validatePlatformSpecific(pathComponent); err != nil {
43 return errors.Join(ErrInvalidPath, err)
44 }
45
46 return nil
47}

Callers 4

ListMethod · 0.92
IsFilesystemSafeFunction · 0.92

Calls 1

validatePlatformSpecificFunction · 0.70

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…