From 089aea99d802a601f5ae090a611464030f15edf3 Mon Sep 17 00:00:00 2001 From: lvyangyang Date: Fri, 6 Nov 2020 19:42:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Ddns=20record=20name?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/dns_recordsets.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/compute/models/dns_recordsets.go b/pkg/compute/models/dns_recordsets.go index e2ff757bf9..5580a88125 100644 --- a/pkg/compute/models/dns_recordsets.go +++ b/pkg/compute/models/dns_recordsets.go @@ -18,12 +18,12 @@ import ( "context" "database/sql" "fmt" + "regexp" "strings" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" - "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -121,11 +121,11 @@ func (manager *SDnsRecordSetManager) ValidateCreateData(ctx context.Context, use return input, err } input.Name = strings.ToLower(input.Name) - if input.Name != "*" && input.Name != "@" { - if !regutils.MatchDomainName(input.Name) { - return input, httperrors.NewInputParameterError("invalid domain name %s", input.Name) - } + rrRegexp := regexp.MustCompile(`^(([a-zA-Z0-9_][a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])|[a-zA-Z0-9_]|\*{1}){1}(\.(([a-zA-Z0-9_][a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])|[a-zA-Z0-9_]))*$|^@{1}$`) + if !rrRegexp.MatchString(input.Name) { + return input, httperrors.NewInputParameterError("invalid record name %s", input.Name) } + if len(input.DnsZoneId) == 0 { return input, httperrors.NewMissingParameterError("dns_zone_id") }