]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Support Gopher type "w" (#889)
authorZachary Lee Andrews <zcrayfish@gmail.com>
Thu, 26 Aug 2021 16:56:08 +0000 (16:56 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 27 Aug 2021 07:50:46 +0000 (07:50 +0000)
Known uses and libwww imply that "w" selector is an absolute URI.

Also updated gopher item-type code list and codes documentation.

src/gopher.cc

index 242e8203ca032fd298bd6edc87e3ce40e30f6c86..7c0e666252739c0cd2177c969b1a017e48c4ac04 100644 (file)
@@ -35,7 +35,7 @@
 #include "MemObject.h"
 #endif
 
-/* gopher type code from rfc. Anawat. */
+// RFC 1436 section 3.8 gopher item-type codes
 #define GOPHER_FILE         '0'
 #define GOPHER_DIRECTORY    '1'
 #define GOPHER_CSO          '2'
 #define GOPHER_GIF          'g'
 #define GOPHER_IMAGE        'I'
 
+// Gopher+ section 2.9 extension types
+// https://github.com/jgoerzen/pygopherd/blob/master/doc/standards/Gopher%2B.txt
+#define GOPHER_PLUS_IMAGE   ':'
+#define GOPHER_PLUS_MOVIE   ';'
+#define GOPHER_PLUS_SOUND   '<'
+
+// non-standard item-type codes
 #define GOPHER_HTML         'h'
 #define GOPHER_INFO         'i'
-
-///  W3 address
 #define GOPHER_WWW          'w'
 #define GOPHER_SOUND        's'
 
-#define GOPHER_PLUS_IMAGE   ':'
-#define GOPHER_PLUS_MOVIE   ';'
-#define GOPHER_PLUS_SOUND   '<'
-
 #define GOPHER_PORT         70
 
 #define TAB                 '\t'
@@ -564,6 +565,10 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
                         icon_url = NULL;
                         break;
 
+                    case GOPHER_WWW:
+                        icon_url = mimeGetIconURL("internal-link");
+                        break;
+
                     default:
                         icon_url = mimeGetIconURL("internal-unknown");
                         break;
@@ -588,6 +593,9 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
                             /* WWW link */
                             snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"http://%s/%s\">%s</A>\n",
                                      icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name));
+                         } else if (gtype == GOPHER_WWW) {
+                            snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"%s\">%s</A>\n",
+                                     icon_url, rfc1738_escape_unescaped(selector), html_quote(name));
                         } else {
                             /* Standard link */
                             snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG border=\"0\" SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",