Skip to content

Octets after ? in gopher:// URL are interpreted as a query #3369

@iamleot

Description

@iamleot

According RFC 4266 a gopher:// URL is:

[...]
A Gopher URL takes the form:

  gopher://<host>:<port>/<gopher-path>

where is one of:

  <gophertype><selector>
  <gophertype><selector>%09<search>
  <gophertype><selector>%09<search>%09<gopher+_string>

[...]

is the Gopher selector string. In the Gopher protocol,
Gopher selector strings are a sequence of octets that may contain any
octets except 09 hexadecimal (US-ASCII HT or tab), 0A hexadecimal
(US-ASCII character LF), and 0D (US-ASCII character CR).
[...]

However, everything after a `?' is ignored.

I did this

I will denote with a S> the server, and C> the client:

S> % nc -l 7070
C> % curl 'gopher://localhost:7070/1/foo?bar'
S> /foo
S> % nc -l 7070
C> % curl 'gopher://localhost:7070/1/foo?'
S> /foo

I expected the following

S> % nc -l 7070
C> % curl 'gopher://localhost:7070/1/foo?bar'
S> /foo?bar
S> % nc -l 7070
C> % curl 'gopher://localhost:7070/1/foo?'
S> /foo?

No ? and (if any) no octets after the ? should be omitted.

curl/libcurl version

% curl -V
curl 7.63.0 (x86_64--netbsd) libcurl/7.63.0 OpenSSL/1.1.0i zlib/1.2.10 libidn2/2.0.5
Release-Date: 2018-12-12
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy

operating system

NetBSD

PS: Please note that AFAICS we have no way to distunguish between a:
gopher://host:port/path and gopher://host:port/path? and so I think
that gopher_do() in lib/gopher.c could not be adjusted to just take
the concatenation of data->state.up.path and data->state.up.query
(in both cases data->state.up.query seems NULL).
Of course, if you have any idea how to better implement that,
feel free to share it and I'll try to write a possible patch!

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions