summaryrefslogtreecommitdiff
path: root/gopher
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-05-09 14:08:33 -0600
committertjpcc <tjp@ctrl-c.club>2023-05-09 14:08:33 -0600
commitd7ffcc43d12c58afdcd5f8498d8016bd35ed4823 (patch)
tree7493ca8e2726542cc0ab421dfdb755ab5fb9d1d5 /gopher
parenta97f6f500f4ec71e842a63e2f2a48f133c2180d4 (diff)
fix gopher request parsing for clients which don't send CRLF
Diffstat (limited to 'gopher')
-rw-r--r--gopher/request.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/gopher/request.go b/gopher/request.go
index 4125af3..0757654 100644
--- a/gopher/request.go
+++ b/gopher/request.go
@@ -25,10 +25,10 @@ func ParseRequest(rdr io.Reader) (*sr.Request, error) {
return &sr.Request{
URL: &url.URL{
Scheme: "gopher",
- Path: path.Clean(strings.TrimSuffix(selector, "\r\n")),
+ Path: path.Clean(selector),
OmitHost: true, //nolint:typecheck
// (for some reason typecheck on drone-ci doesn't realize OmitHost is a field in url.URL)
- RawQuery: url.QueryEscape(strings.TrimSuffix(search, "\r\n")),
+ RawQuery: url.QueryEscape(search),
},
}, nil
}
@@ -68,5 +68,5 @@ func readFullRequest(rdr io.Reader) (string, string, error) {
}
selector, search, _ := bytes.Cut(buf, []byte{'\t'})
- return string(selector), string(search), nil
+ return strings.TrimRight(string(selector), "\r\n"), strings.TrimRight(string(search), "\r\n"), nil
}