Skip to content

Commit c3c5843

Browse files
authored
fix(terabox): panic due to slice out of range (#7499 close #7487)
1 parent 6c38c59 commit c3c5843

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/terabox/util.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ func (d *Terabox) request(rurl string, method string, callback base.ReqCallback,
9191
return d.request(rurl, method, callback, resp, true)
9292
}
9393
} else if errno == -6 {
94-
log.Debugln(res.Header())
95-
d.url_domain_prefix = res.Header()["Url-Domain-Prefix"][0]
96-
d.base_url = "https://" + d.url_domain_prefix + ".terabox.com"
97-
log.Debugln("Redirect base_url to", d.base_url)
98-
return d.request(rurl, method, callback, resp, noRetry...)
94+
header := res.Header()
95+
log.Debugln(header)
96+
urlDomainPrefix := header.Get("Url-Domain-Prefix")
97+
if len(urlDomainPrefix) > 0 {
98+
d.url_domain_prefix = urlDomainPrefix
99+
d.base_url = "https://" + d.url_domain_prefix + ".terabox.com"
100+
log.Debugln("Redirect base_url to", d.base_url)
101+
return d.request(rurl, method, callback, resp, noRetry...)
102+
}
99103
}
100104
return res.Body(), nil
101105
}

0 commit comments

Comments
 (0)