validateTextContent ensures content is valid UTF-8 without null bytes
(content []byte)
| 69 | |
| 70 | // validateTextContent ensures content is valid UTF-8 without null bytes |
| 71 | func (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 |
| 87 | func (p *FetchPlugin) fetch(urlStr string) (string, error) { |