Fetch an IPv6 source host written without a port (closes #295)
check / check (push) Canceled after 0s

The fetcher's check of a source URL cut a port off the host with
net.SplitHostPort, which fails when an IPv6 address in brackets has no
port, so the brackets stayed on, the name lookup failed and the request
answered 500. The check now parses the URL and takes the host from
Hostname(), which drops the brackets with or without a port, so the
address is looked up and a private one is refused with 403.

Model: opus-5-5
This commit is contained in:
2026-10-16 02:49:55 +00:00
committed by clawbot
parent 1aacf6cbf6
commit 6f50eb20df
2 changed files with 14 additions and 8 deletions
+8 -8
View File
@@ -473,16 +473,16 @@ func validateURL(ctx context.Context, rawURL string, allowHTTP bool) error {
return ErrUnsupportedScheme
}
// Parse to extract host
host := extractHost(rawURL)
if host == "" {
return ErrInvalidHost
parsedURL, err := neturl.Parse(rawURL)
if err != nil {
return fmt.Errorf("%w: %w", ErrInvalidHost, err)
}
// Remove port if present
h, _, err := net.SplitHostPort(host)
if err == nil {
host = h
// Hostname drops any port, and the brackets of an IPv6 address whether
// or not a port follows them
host := parsedURL.Hostname()
if host == "" {
return ErrInvalidHost
}
// Block obvious localhost patterns