diff options
Diffstat (limited to 'network/elinks/patches/0002-gopher_index_queries.patch')
-rw-r--r-- | network/elinks/patches/0002-gopher_index_queries.patch | 125 |
1 files changed, 73 insertions, 52 deletions
diff --git a/network/elinks/patches/0002-gopher_index_queries.patch b/network/elinks/patches/0002-gopher_index_queries.patch index ce92695a0a..662fd13a7f 100644 --- a/network/elinks/patches/0002-gopher_index_queries.patch +++ b/network/elinks/patches/0002-gopher_index_queries.patch @@ -1,71 +1,53 @@ ####################################################################### -# elinks by default generates its own search query form when it sees -# a type 7 index entity. The problem is that it didn't read the -# served results page and instead generated another search page after -# you had entered the first. This patch fixes that and in my tests it -# seems to work so far. I've also added a primitive debug log. +# Fix for type 7 entities. # dave@slackbuilds.org ####################################################################### -diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c ---- a/src/protocol/gopher/gopher.c 2020-01-08 05:37:57.443382095 +0000 -+++ b/src/protocol/gopher/gopher.c 2020-01-08 05:36:42.849199857 +0000 -@@ -43,6 +43,34 @@ - #include "util/memory.h" - #include "util/string.h" +diff -Naur '--exclude=.git' bb/src/protocol/gopher/gopher.c cc/src/protocol/gopher/gopher.c +--- bb/src/protocol/gopher/gopher.c 2020-01-13 22:35:13.663935305 +0000 ++++ cc/src/protocol/gopher/gopher.c 2020-01-13 23:16:00.053003768 +0000 +@@ -197,7 +197,7 @@ + command->length = strlen(command->source); + } -+#ifdef HAVE_FCNTL_H -+#include <fcntl.h> /* OS/2 needs this after sys/types.h */ -+#endif -+ -+/* To enable logging for debugging purposes. */ -+#if 0 -+ -+#define LOGFILE "/tmp/log" -+ -+static void -+debug_log(unsigned char *data, int NL) -+{ -+ int fd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT, 0622); -+ -+ if (fd == -1) return; -+ -+ set_bin(fd); -+ write(fd, data, strlen(data)); -+ if (NL) -+ write(fd, "\n", 1); -+ close(fd); -+} -+#undef LOGFILE -+ -+#else -+#define debug_log(data, len) -+#endif -+ - struct module gopher_protocol_module = struct_module( - /* name: */ N_("Gopher"), - /* options: */ NULL, -@@ -219,11 +247,13 @@ +-static struct connection_state init_gopher_index_cache_entry(struct connection *conn); ++/* static struct connection_state init_gopher_index_cache_entry(struct connection *conn); */ + + static struct connection_state + add_gopher_command(struct connection *conn, struct string *command, +@@ -205,7 +205,7 @@ + unsigned char *selector, int selectorlen) + { + unsigned char *query; +- int querylen; ++ int querylen = 0; + + if (!init_string(command)) + return connection_state(S_OUT_OF_MEM); +@@ -218,13 +218,14 @@ + /* Exclude '?' */ if (query) selectorlen -= 1; query = NULL; - querylen = 0; +- querylen = 0; - } else { - query += 1; + } else if (entity == GOPHER_INDEX) { -+ /* fix query size to not include the search= part */ ++ /* fix query size to not include the search= part */ + query += 8; querylen = selector + selectorlen - query; /* Exclude '?' */ - selectorlen -= querylen + 1; -+ /* fix selector length to fit with query */ +- if (querylen >= 7 && !c_strncasecmp(query, "search=", 7)) { ++ /* fix selector length to fit with query */ + selectorlen -= querylen + 8; - if (querylen >= 7 && !c_strncasecmp(query, "search=", 7)) { ++ if (querylen >= 7 && !c_strncasecmp(query, "submit=", 7)) { query += 7; querylen -= 7; -@@ -233,9 +263,11 @@ + } +@@ -233,9 +234,11 @@ switch (entity) { case GOPHER_INDEX: /* No search required? */ -+ /* Don't display the form page */ ++ /* Don't display the form page */ if (!query) { done_string(command); - return init_gopher_index_cache_entry(conn); @@ -74,19 +56,58 @@ diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c } add_uri_decoded(command, selector, selectorlen, 0); -@@ -371,13 +403,14 @@ +@@ -371,13 +374,14 @@ add_gopher_search_field(struct string *buffer, const unsigned char *text, const unsigned char *addr) { -+ /* Not *every* query is a search */ ++ /* Not *every* query is a search! */ add_format_to_string(buffer, "<form action=\"%s\">" "<table>" "<td> </td>" "<td>%s:</td>" - "<td><input maxlength=\"256\" name=\"search\" value=\"\"></td>" +- "<td><input maxlength=\"256\" name=\"search\" value=\"\"></td>" - "<td><input type=submit value=\"Search\"></td>" ++ "<td><input maxlength=\"256\" name=\"submit\" value=\"\"></td>" + "<td><input type=submit value=\"Submit\"></td>" "</table>" "</form>", addr, text); +@@ -662,6 +666,7 @@ + } + + /* Display a Gopher Index document. */ ++/* Use the page that the gopher site sends us + static struct connection_state + init_gopher_index_cache_entry(struct connection *conn) + { +@@ -674,9 +679,9 @@ + + where = get_uri_string(conn->uri, URI_PUBLIC); + +- /* TODO: Use different function when using UTF-8 ++ TODO: Use different function when using UTF-8 + * in terminal (decode_uri_for_display replaces +- * bytes of UTF-8 characters width '*'). */ ++ * bytes of UTF-8 characters width '*'). * + if (where) decode_uri_for_display(where); + + add_format_to_string(&buffer, +@@ -695,7 +700,7 @@ + + mem_free_if(where); + +- /* FIXME: I think this needs a form or something */ ++ * FIXME: I think this needs a form or something * + + add_fragment(conn->cached, conn->from, buffer.source, buffer.length); + conn->from += buffer.length; +@@ -707,7 +712,7 @@ + ? connection_state(S_OK) + : connection_state(S_OUT_OF_MEM); + } +- ++*/ + + static void + read_gopher_response_data(struct socket *socket, struct read_buffer *rb) |