isLocalFileSrc returns true if src is a local file path. Any URI with a scheme (http:, cid:, data:, ftp:, blob:, file:, etc.) or protocol-relative URL (//host/...) is rejected.
(src string)
| 993 | // Any URI with a scheme (http:, cid:, data:, ftp:, blob:, file:, etc.) |
| 994 | // or protocol-relative URL (//host/...) is rejected. |
| 995 | func isLocalFileSrc(src string) bool { |
| 996 | trimmed := strings.TrimSpace(src) |
| 997 | if trimmed == "" { |
| 998 | return false |
| 999 | } |
| 1000 | if strings.HasPrefix(trimmed, "//") { |
| 1001 | return false |
| 1002 | } |
| 1003 | return !uriSchemeRegexp.MatchString(trimmed) |
| 1004 | } |
| 1005 | |
| 1006 | // generateCID returns a random UUID string suitable for use as a Content-ID. |
| 1007 | // UUIDs contain only [0-9a-f-], which is inherently RFC-safe and unique, |
no outgoing calls