MCPcopy
hub / github.com/danielmiessler/Fabric / validateTextContent

Method validateTextContent

internal/plugins/template/fetch.go:71–84  ·  view source on GitHub ↗

validateTextContent ensures content is valid UTF-8 without null bytes

(content []byte)

Source from the content-addressed store, hash-verified

69
70// validateTextContent ensures content is valid UTF-8 without null bytes
71func (p *FetchPlugin) validateTextContent(content []byte) error {
72 debugf("Fetch: validating content length=%d bytes", len(content))
73
74 if !utf8.Valid(content) {
75 return errors.New(i18n.T("fetch_content_not_utf8"))
76 }
77
78 if bytes.Contains(content, []byte{0}) {
79 return errors.New(i18n.T("fetch_content_null_bytes"))
80 }
81
82 debugf("Fetch: content validation successful")
83 return nil
84}
85
86// fetch retrieves content from a URL with safety checks
87func (p *FetchPlugin) fetch(urlStr string) (string, error) {

Callers 1

fetchMethod · 0.95

Calls 2

TFunction · 0.92
debugfFunction · 0.85

Tested by

no test coverage detected