Update to go1.23.5

This commit is contained in:
Vorapol Rinsatitnon
2025-01-26 14:10:14 +08:00
parent bd5ec5d0e7
commit 716e5b5d05
14 changed files with 264 additions and 131 deletions

View File

@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"net"
"net/netip"
"net/url"
"reflect"
"runtime"
@@ -434,8 +435,10 @@ func matchURIConstraint(uri *url.URL, constraint string) (bool, error) {
}
}
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") ||
net.ParseIP(host) != nil {
// netip.ParseAddr will reject the URI IPv6 literal form "[...]", so we
// check if _either_ the string parses as an IP, or if it is enclosed in
// square brackets.
if _, err := netip.ParseAddr(host); err == nil || (strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]")) {
return false, fmt.Errorf("URI with IP (%q) cannot be matched against constraints", uri.String())
}