Fetcher::URLValidator
Constants
IPv4 CIDR ranges blocked for SSRF protection. Format: {prefix_as_uint32, prefix_length, description}
DNS rebinding mitigation: track recently validated hostnames and their IPs
Class methods
Extract host/domain from a URL string. Returns "default" on error.
Permissive scheme check: returns true for nil/empty, relative URLs (no colon), and http/https URLs. Returns false only for explicitly dangerous schemes (javascript:, data:, vbscript:, file:, etc.).
This is intentionally more permissive than valid?, which requires
a full http/https URL with a valid host. safe_scheme? is used for
secondary URLs (comment URLs, author URLs, attachment URLs) that
may legitimately be relative paths like "/comments/123".
Both methods block dangerous schemes -- safe_scheme? via the
DANGEROUS_SCHEMES blacklist, valid? via the ALLOWED_SCHEMES
whitelist. The defense-in-depth is: secondary URLs go through
safe_scheme? (permissive), primary URLs go through valid? (strict).
Backwards-compatible store. We encapsulate the mutable cache in ValidatedIpStore but keep a class-level default instance so existing call-sites remain functional without signature changes.