mirror of
https://git.sr.ht/~adnano/go-gemini
synced 2024-11-23 12:42:13 +01:00
request: Allow User in URLs
This commit is contained in:
parent
1c32f4d5aa
commit
087c8a62e7
@ -102,20 +102,12 @@ func ReadRequest(r io.Reader) (*Request, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if u.User != nil {
|
||||
// User is not allowed
|
||||
return nil, ErrInvalidURL
|
||||
}
|
||||
return &Request{URL: u}, nil
|
||||
}
|
||||
|
||||
// Write writes a Gemini request in wire format.
|
||||
// This method consults the request URL only.
|
||||
func (r *Request) Write(w *bufio.Writer) error {
|
||||
if r.URL.User != nil {
|
||||
// User is not allowed
|
||||
return ErrInvalidURL
|
||||
}
|
||||
url := r.URL.String()
|
||||
if len(url) > 1024 {
|
||||
return ErrInvalidRequest
|
||||
|
@ -46,14 +46,6 @@ func TestReadRequest(t *testing.T) {
|
||||
Raw: "gemini://example.com",
|
||||
Err: io.EOF,
|
||||
},
|
||||
{
|
||||
Raw: "gemini://user:password@example.com\r\n",
|
||||
Err: ErrInvalidURL,
|
||||
},
|
||||
{
|
||||
Raw: "https://user:password@example.net\r\n",
|
||||
Err: ErrInvalidURL,
|
||||
},
|
||||
{
|
||||
// 1030 bytes
|
||||
Raw: maxURL + "xxxxxx",
|
||||
@ -121,14 +113,6 @@ func TestWriteRequest(t *testing.T) {
|
||||
Req: newRequest(maxURL + "x"),
|
||||
Err: ErrInvalidRequest,
|
||||
},
|
||||
{
|
||||
Req: newRequest("gemini://user:password@example.org"),
|
||||
Err: ErrInvalidURL,
|
||||
},
|
||||
{
|
||||
Req: newRequest("https://user:password@example.org"),
|
||||
Err: ErrInvalidURL,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user