Documentation
¶
Index ¶
- Variables
- func CleanRelativePath(p string) (string, error)
- func EnsureUnderRoot(root, candidate string) (string, error)
- func IsLoopbackHost(u *url.URL) bool
- func NewHTTPClient(timeout time.Duration) *http.Client
- func ReadAllWithLimit(r io.Reader, limit int64) ([]byte, error)
- func SafeJoinUnder(root, rel string) (string, error)
- func ValidateHTTPURL(raw string) (*url.URL, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBodyTooLarge = errors.New("response body too large")
ErrBodyTooLarge indicates a response body exceeded the configured read limit.
Functions ¶
func CleanRelativePath ¶
CleanRelativePath validates and normalizes a relative path. It rejects absolute paths and parent traversal segments.
func EnsureUnderRoot ¶
EnsureUnderRoot verifies candidate resolves under root and returns an absolute normalized path.
func IsLoopbackHost ¶
IsLoopbackHost reports whether the URL host is localhost/loopback.
func NewHTTPClient ¶
NewHTTPClient creates a hardened HTTP client suitable for untrusted upstream content.
func ReadAllWithLimit ¶
ReadAllWithLimit reads from r and fails if content exceeds limit bytes.
func SafeJoinUnder ¶
SafeJoinUnder joins a validated relative path under root and verifies the final path remains inside root.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.