Skip to content

Commit be2586f

Browse files
authored
Merge pull request #309 from tencentyun/feature_jojoliang_47be8fb3
不允许请求url为空
2 parents 864157e + 3848c13 commit be2586f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cos.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
const (
2828
// Version current go sdk version
29-
Version = "0.7.64"
29+
Version = "0.7.65"
3030
UserAgent = "cos-go-sdk-v5/" + Version
3131
contentTypeXML = "application/xml"
3232
defaultServiceBaseURL = "http://service.cos.myqcloud.com"
@@ -87,6 +87,10 @@ func (*BaseURL) innerCheck(u *url.URL, reg *regexp.Regexp) bool {
8787
if domainSuffix.MatchString(urlStr) && !reg.MatchString(urlStr) {
8888
return false
8989
}
90+
host := u.Hostname()
91+
if domainSuffix.MatchString(host) && !reg.MatchString(u.Scheme+"://"+host) {
92+
return false
93+
}
9094
return true
9195
}
9296

@@ -280,6 +284,9 @@ func (c *Client) newRequest(ctx context.Context, baseURL *url.URL, uri, method s
280284
if c.invalidURL {
281285
return nil, invalidBucketErr
282286
}
287+
if baseURL == nil {
288+
return nil, invalidBucketErr
289+
}
283290
if !checkURL(baseURL) {
284291
host := baseURL.String()
285292
if c.BaseURL.MetaInsightURL != baseURL || !metaInsightHostPrefix.MatchString(host) {

0 commit comments

Comments
 (0)