summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--finger/request.go20
-rw-r--r--finger/serve.go2
2 files changed, 8 insertions, 14 deletions
diff --git a/finger/request.go b/finger/request.go
index 5eae6b6..14058ca 100644
--- a/finger/request.go
+++ b/finger/request.go
@@ -13,18 +13,15 @@ import (
// ForwardingDenied is returned in response to requests for forwarding service.
var ForwardingDenied = errors.New("Finger forwarding service denied.")
-// InvalidFingerQuery is sent when a client doesn't properly format the query.
-var InvalidFingerQuery = errors.New("Invalid finger query.")
-
// ParseRequest builds a sliderule.Request by reading a finger protocol request.
//
// At the time of writing, there is no firm standard on how to represent finger
// queries as URLs (the finger protocol itself predates URLs entirely), but there
// are a few helpful resources to go from.
-// - The lynx browser supports finger URLs and documents the forms they may take:
-// https://lynx.invisible-island.net/lynx_help/lynx_url_support.html#finger_url
-// - There is an IETF draft:
-// https://datatracker.ietf.org/doc/html/draft-ietf-uri-url-finger
+// - The lynx browser supports finger URLs and documents the forms they may take:
+// https://lynx.invisible-island.net/lynx_help/lynx_url_support.html#finger_url
+// - There is an IETF draft:
+// https://datatracker.ietf.org/doc/html/draft-ietf-uri-url-finger
//
// As this function builds a *sliderule.Request (which is mostly a wrapper around a URL)
// from nothing but an io.Reader, it doesn't have the context of the hostname which
@@ -53,13 +50,10 @@ func ParseRequest(rdr io.Reader) (*types.Request, error) {
return nil, err
}
- if len(line) < 2 || line[len(line)-2] != '\r' {
- return nil, InvalidFingerQuery
- }
-
- line = strings.TrimSuffix(line, "\r\n")
+ line = strings.TrimRight(line, " \t\r\n")
+ line = strings.TrimLeft(line, " \t")
line = strings.TrimPrefix(line, "/W")
- line = strings.TrimLeft(line, " ")
+ line = strings.TrimLeft(line, " \t")
username, hostname, _ := strings.Cut(line, "@")
if strings.Contains(hostname, "@") {
diff --git a/finger/serve.go b/finger/serve.go
index db96088..f959373 100644
--- a/finger/serve.go
+++ b/finger/serve.go
@@ -6,8 +6,8 @@ import (
"io"
"net"
- "tildegit.org/tjp/sliderule/internal/types"
"tildegit.org/tjp/sliderule/internal"
+ "tildegit.org/tjp/sliderule/internal/types"
"tildegit.org/tjp/sliderule/logging"
)