curl-library
Re: Gopher [Was ""]
Date: Fri, 26 Feb 2016 15:00:55 -0800
What I suspect that original code was going was parsing the content
from a gopher server (and in fact, taking some shortcuts that may have
happened to work for original use-case). The actual URI is the second
component of an appropriate gopher line, and to be used unadulterated.
What I think the previous code was supposed to do is take a raw line
from a gopher server and eliminate it's "status", and use the
user-visible component of the returned content as the URI. That sort
of parsing is better left for a higher-level client. This patch
removes the test of path length and stripping characters, but
preserves tab handling (arguably still removable) and escaping.
ref: rfc1436
Index: ./curl/lib/gopher.c
==================================================================
--- ./curl/lib/gopher.c
+++ ./curl/lib/gopher.c
@@ -84,36 +84,23 @@
char *sel_org = NULL;
ssize_t amount, k;
int len;
*done = TRUE; /* unconditionally */
+ size_t j, i;
- /* Create selector. Degenerate cases: / and /1 => convert to "" */
- if(strlen(path) <= 2) {
- sel = (char *)"";
- len = (int)strlen(sel);
- }
- else {
- char *newp;
- size_t j, i;
+ /* ... then turn ? into TAB for search servers, Veronica, etc. ... */
+ j = strlen (path);
+ for (i = 0; i < j; i++)
+ if (path[i] == '?')
+ path[i] = '\x09';
- /* Otherwise, drop / and the first character (i.e., item type) ... */
- newp = path;
- newp+=2;
-
- /* ... then turn ? into TAB for search servers, Veronica, etc. ... */
- j = strlen(newp);
- for(i=0; i<j; i++)
- if(newp[i] == '?')
- newp[i] = '\x09';
-
- /* ... and finally unescape */
- sel = curl_easy_unescape(data, newp, 0, &len);
- if(!sel)
- return CURLE_OUT_OF_MEMORY;
- sel_org = sel;
- }
+ /* ... and finally unescape */
+ sel = curl_easy_unescape (data, path, 0, &len);
+ if (!sel)
+ return CURLE_OUT_OF_MEMORY;
+ sel_org = sel;
/* We use Curl_write instead of Curl_sendf to make sure the entire buffer is
sent, which could be sizeable with long selectors. */
k = curlx_uztosz(len);
On 2/26/16, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Fri, 26 Feb 2016, bch wrote:
>
>> You're probably right, re: "the number of people using gopher with
>> (lib)curl" --I was wondering if there was deep knowledge contained by you
>> (@bagder) or anybody else...
>
> I wrote the first gopher code before curl was even called curl, back in 1997
> or so, but I only used it for a short period of time and I really can't
> remember many specific details. Sorry.
>
>> I may start hacking this for fun (not profit).
>
> We'll welcome your help!
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-02-27