From d7ffcc43d12c58afdcd5f8498d8016bd35ed4823 Mon Sep 17 00:00:00 2001
From: tjpcc <tjp@ctrl-c.club>
Date: Tue, 9 May 2023 14:08:33 -0600
Subject: fix gopher request parsing for clients which don't send CRLF

---
 gopher/request.go | 6 +++---
 1 file 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
 }
-- 
cgit v1.2.3