diff options
author | bptato <nincsnevem662@gmail.com> | 2020-10-21 10:56:36 +0000 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2020-10-21 10:56:36 +0000 |
commit | 4bc97ce307f717166909f303d766d495fb477e6a (patch) | |
tree | 9cfdb50b1264a3768e89d57703694ea285225448 /file.c | |
parent | Update ChangeLog (diff) | |
download | w3m-4bc97ce307f717166909f303d766d495fb477e6a.tar.gz w3m-4bc97ce307f717166909f303d766d495fb477e6a.zip |
Improved gopher support
Diffstat (limited to '')
-rw-r--r-- | file.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -1959,7 +1959,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, #endif /* USE_NNTP */ #ifdef USE_GOPHER else if (pu.scheme == SCM_GOPHER) { - switch (*pu.file) { + switch (pu.file[strlen(pu.file)-1]) { case '0': t = "text/plain"; break; @@ -7393,8 +7393,9 @@ Str loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset) { Str volatile tmp; - Str lbuf, name, file, host, port; + Str lbuf, name, file, host, port, type; char *volatile p, *volatile q; + int link; MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; #ifdef USE_M17N wc_ces doc_charset = DocumentCharset; @@ -7440,6 +7441,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset) for (q = p; *q && *q != '\t' && *q != '\r' && *q != '\n'; q++) ; port = Strnew_charp_n(p, q - p); + link = 1; switch (name->ptr[0]) { case '0': p = "[text file]"; @@ -7459,15 +7461,22 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, wc_ces * charset) case 'h': p = "[HTML]"; break; + case 'i': + link = 0; + break; default: p = "[unsupported]"; break; } - q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr, - "/", file->ptr, NULL)->ptr; - Strcat_m_charp(tmp, "<a href=\"", - html_quote(url_encode(q, NULL, *charset)), - "\">", p, html_quote(name->ptr + 1), "</a>\n", NULL); + type = Strsubstr(name, 0, 1); + q = Strnew_m_charp("gopher://", host->ptr, ":", port->ptr, file->ptr, type->ptr, NULL)->ptr; + if(link) { + Strcat_m_charp(tmp, "<a href=\"", + html_quote(url_encode(q, NULL, *charset)), + "\">", p, " ", html_quote(name->ptr + 1), "</a><br>\n", NULL); + } else { + Strcat_m_charp(tmp, "<p>", html_quote(name->ptr + 1), "</p>\n", NULL); + } } gopher_end: |