1
0
Fork 0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-04-26 11:45:14 +02:00

request: Allow User in URLs

This commit is contained in:
Adnan Maolood 2021-02-16 00:55:54 -05:00
parent 2157b35c0b
commit 779be8b95b
2 changed files with 0 additions and 24 deletions

View File

@ -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

View File

@ -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 {