mirror of
https://github.com/tinyauthapp/tinyauth.git
synced 2026-08-25 23:03:35 +08:00
fix: allow for undescores and leading hyphens in domain validator (#1088)
This commit is contained in:
@@ -119,7 +119,15 @@ func (v *DomainValidator) getHostname(hostname string) (string, error) {
|
||||
if net.ParseIP(hostname) != nil {
|
||||
return "", fmt.Errorf("ip addresses are not supported")
|
||||
}
|
||||
hostname, err := idna.Lookup.ToASCII(hostname)
|
||||
i := idna.New(
|
||||
idna.MapForLookup(),
|
||||
idna.Transitional(false),
|
||||
idna.BidiRule(),
|
||||
idna.StrictDomainName(false),
|
||||
idna.CheckHyphens(false),
|
||||
idna.CheckJoiners(false),
|
||||
)
|
||||
hostname, err := i.ToASCII(hostname)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to convert hostname to ascii: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user