####################################################################### # Fix for type 7 entities. # dave@slackbuilds.org ####################################################################### 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); } -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; - } else { - query += 1; + } else if (entity == GOPHER_INDEX) { + /* fix query size to not include the search= part */ + query += 8; querylen = selector + selectorlen - query; /* Exclude '?' */ - selectorlen -= querylen + 1; - if (querylen >= 7 && !c_strncasecmp(query, "search=", 7)) { + /* fix selector length to fit with query */ + selectorlen -= querylen + 8; + if (querylen >= 7 && !c_strncasecmp(query, "submit=", 7)) { query += 7; querylen -= 7; } @@ -233,9 +234,11 @@ switch (entity) { case GOPHER_INDEX: /* No search required? */ + /* Don't display the form page */ if (!query) { done_string(command); - return init_gopher_index_cache_entry(conn); + add_uri_decoded(command, selector, selectorlen, 0); + break; } add_uri_decoded(command, selector, selectorlen, 0); @@ -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! */ add_format_to_string(buffer, "
", 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)