Skip to content

Commit defa30c

Browse files
committed
Fix nil pointer dereference
1 parent 951ed75 commit defa30c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/http.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var (
3535
anyway = "0"
3636
scheme = "http"
3737
onion = "archivecaslytosk.onion" // archiveiya74codqgiixo33q62qlrqtkgmcitqx5u2oeqnmn5bpcbiyd.onion
38-
cookie = "cf_clearance=dd7e157eb2d43acf2decfafd13c650dd80d825b5-1600696752-KXZXFYWE"
38+
cookie = ""
3939
timeout = 120 * time.Second
4040
baseuri *url.URL
4141
domains = []string{
@@ -90,14 +90,15 @@ func (wbrc *Archiver) fetch(s string, ch chan<- string) {
9090
data := url.Values{
9191
"submitid": {wbrc.submitid},
9292
"anyway": {anyway},
93-
"url": {s},
93+
"url": {url.QueryEscape(s)},
9494
}
95+
uri := baseuri.String()
9596
req, err := http.NewRequest("POST", baseuri.String()+"/submit/", strings.NewReader(data.Encode()))
9697
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
9798
req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
9899
req.Header.Add("User-Agent", userAgent)
99-
req.Header.Add("Referer", baseuri.String())
100-
req.Header.Add("Origin", baseuri.String())
100+
req.Header.Add("Referer", uri)
101+
req.Header.Add("Origin", uri)
101102
req.Header.Add("Host", baseuri.Hostname())
102103
req.Header.Add("Cookie", wbrc.getCookie())
103104
resp, err := wbrc.httpClient.Do(req)
@@ -109,7 +110,7 @@ func (wbrc *Archiver) fetch(s string, ch chan<- string) {
109110

110111
code := resp.StatusCode / 100
111112
if code == 1 || code == 4 || code == 5 {
112-
final := fmt.Sprintf("%v?url=%s", baseuri.String(), s)
113+
final := fmt.Sprintf("%s?url=%s", uri, s)
113114
ch <- final
114115
return
115116
}
@@ -168,7 +169,6 @@ func (wbrc *Archiver) getSubmitID(url string) (string, error) {
168169
if err != nil {
169170
return "", err
170171
}
171-
172172
defer resp.Body.Close()
173173

174174
if resp.StatusCode != http.StatusOK {

0 commit comments

Comments
 (0)