]> 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)
committerAmos Jeffries <yadij@users.noreply.github.com>
Tue, 10 May 2022 08:00:04 +0000 (20:00 +1200)
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 576a3f7b146f19d0e46ac95f31863613d64ae0b9..c4d1aeaad8dd72d22a85ff527cfe1c28b7f84a99 100644 (file)
@@ -34,7 +34,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'
@@ -572,6 +573,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;
@@ -596,6 +601,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",