From 08b044fcddda4280f5ca3ca69db7a6748a222a6b Mon Sep 17 00:00:00 2001 From: David Woodfall Date: Thu, 30 Nov 2017 21:55:02 +0000 Subject: network/elinks: Patched to fix gopher index queries. Signed-off-by: David Spencer --- network/elinks/elinks.SlackBuild | 8 +- network/elinks/gopher-html.patch | 33 --------- network/elinks/gopher_html_links.patch | 39 ++++++++++ network/elinks/gopher_index_queries.patch | 119 ++++++++++++++++++++++++++++++ 4 files changed, 164 insertions(+), 35 deletions(-) delete mode 100644 network/elinks/gopher-html.patch create mode 100644 network/elinks/gopher_html_links.patch create mode 100644 network/elinks/gopher_index_queries.patch (limited to 'network') diff --git a/network/elinks/elinks.SlackBuild b/network/elinks/elinks.SlackBuild index 4e01d232d48d..24505e81ffc2 100644 --- a/network/elinks/elinks.SlackBuild +++ b/network/elinks/elinks.SlackBuild @@ -26,7 +26,7 @@ PRGNAM=elinks VERSION=${VERSION:-git20131231} -BUILD=${BUILD:-4} +BUILD=${BUILD:-6} TAG=${TAG:-_SBo} if [ -z "$ARCH" ]; then @@ -71,7 +71,11 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; -patch --verbose -p1 < $CWD/gopher-html.patch +# Next patch fixes URL: html links +patch --verbose -p1 < $CWD/gopher_html_links.patch + +# Next patch fixes index queries +patch --verbose -p1 < $CWD/gopher_index_queries.patch [ -n "$NOMOUSE" ] && mouse="--disable-mouse" [ -n "$NOGPM" ] && gpm="--without-gpm" diff --git a/network/elinks/gopher-html.patch b/network/elinks/gopher-html.patch deleted file mode 100644 index 350f57772139..000000000000 --- a/network/elinks/gopher-html.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c ---- a/src/protocol/gopher/gopher.c 2013-12-18 15:38:57.000000000 +0000 -+++ b/src/protocol/gopher/gopher.c 2017-11-15 23:10:19.758394411 +0000 -@@ -277,6 +277,10 @@ - struct string command; - enum gopher_entity entity = DEFAULT_GOPHER_ENTITY; - unsigned char *selector = conn->uri->data; -+ unsigned char *URI = "hURI%3"; -+ unsigned char *URL = "hURL%3"; -+ unsigned char *CURI = "HURI%3"; -+ unsigned char *CURL = "HURL%3"; - int selectorlen = conn->uri->datalen; - struct gopher_entity_info *entity_info; - size_t size; -@@ -288,6 +292,18 @@ - selectorlen--; - } - -+ if(strstr(selector, URL) != NULL || strstr(selector, URI) != NULL) { -+ entity = GOPHER_HTML; -+ *selector++; -+ selectorlen--; -+ } -+ -+ if(strstr(selector, CURL) != NULL || strstr(selector, CURI) != NULL) { -+ entity = GOPHER_CHTML; -+ *selector++; -+ selectorlen--; -+ } -+ - /* This is probably a hack. It serves as a work around when no entity is - * available in the Gopher URI. Instead of segfaulting later the content - * will be served as application/octet-stream. However, it could diff --git a/network/elinks/gopher_html_links.patch b/network/elinks/gopher_html_links.patch new file mode 100644 index 000000000000..4e34e9cdbca4 --- /dev/null +++ b/network/elinks/gopher_html_links.patch @@ -0,0 +1,39 @@ +################################################################ +# There is a problem that html links that contain URL:htpp://... +# aren't being followed. This fixes that issue and also chtml. +# Normally those kind of links go to a redirect page that the +# server generates, which then sends you on your way. +############################################################### +diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c +--- a/src/protocol/gopher/gopher.c 2013-12-18 15:38:57.000000000 +0000 ++++ b/src/protocol/gopher/gopher.c 2017-11-15 23:10:19.758394411 +0000 +@@ -277,6 +277,10 @@ + struct string command; + enum gopher_entity entity = DEFAULT_GOPHER_ENTITY; + unsigned char *selector = conn->uri->data; ++ unsigned char *URI = "hURI%3"; ++ unsigned char *URL = "hURL%3"; ++ unsigned char *CURI = "HURI%3"; ++ unsigned char *CURL = "HURL%3"; + int selectorlen = conn->uri->datalen; + struct gopher_entity_info *entity_info; + size_t size; +@@ -288,6 +292,18 @@ + selectorlen--; + } + ++ if(strstr(selector, URL) != NULL || strstr(selector, URI) != NULL) { ++ entity = GOPHER_HTML; ++ *selector++; ++ selectorlen--; ++ } ++ ++ if(strstr(selector, CURL) != NULL || strstr(selector, CURI) != NULL) { ++ entity = GOPHER_CHTML; ++ *selector++; ++ selectorlen--; ++ } ++ + /* This is probably a hack. It serves as a work around when no entity is + * available in the Gopher URI. Instead of segfaulting later the content + * will be served as application/octet-stream. However, it could diff --git a/network/elinks/gopher_index_queries.patch b/network/elinks/gopher_index_queries.patch new file mode 100644 index 000000000000..17d2ac4b3e91 --- /dev/null +++ b/network/elinks/gopher_index_queries.patch @@ -0,0 +1,119 @@ +####################################################################### +# 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. +####################################################################### +diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c +--- a/src/protocol/gopher/gopher.c 2017-11-24 19:12:52.495714437 +0000 ++++ b/src/protocol/gopher/gopher.c 2017-11-30 12:56:38.872336516 +0000 +@@ -43,6 +43,34 @@ + #include "util/memory.h" + #include "util/string.h" + ++#ifdef HAVE_FCNTL_H ++#include /* OS/2 needs this after sys/types.h */ ++#endif ++ ++/* To enable logging for debugging purposes. */ ++#if 1 ++ ++#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,23 +247,31 @@ + if (query) selectorlen -= 1; + query = NULL; + querylen = 0; +- } else { +- query += 1; ++ } else if (entity == GOPHER_INDEX) { ++ /* fix query size to not include the seach= part */ ++ query += 8; + querylen = selector + selectorlen - query; + /* Exclude '?' */ +- selectorlen -= querylen + 1; ++ /* fix selector length to fit with query */ ++ selectorlen -= querylen + 8; + if (querylen >= 7 && !c_strncasecmp(query, "search=", 7)) { + query += 7; + querylen -= 7; + } ++ debug_log("selector:", 1); ++ debug_log(selector, 1); ++ debug_log("query:", 1); ++ debug_log(query, 1); + } + + 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); +@@ -343,6 +379,10 @@ + gopher->entity = entity_info; + gopher->commandlen = command.length; + ++debug_log("439 gopher->entity:", 1); ++debug_log(gopher->entity, 1); ++debug_log("437 command.source:", 1); ++debug_log(command.source, 1); + memcpy(gopher->command, command.source, command.length); + done_string(&command); + +@@ -377,7 +417,7 @@ + " " + "%s:" + "" +- "" ++ "" + "" + "", + addr, text); +@@ -726,7 +766,8 @@ + /* Now read the data from the socket */ + switch (gopher->entity->type) { + case GOPHER_DIRECTORY: +- case GOPHER_INDEX: ++/* Don't do directory list for cgi output (7) ++ case GOPHER_INDEX: */ + state = read_gopher_directory_data(conn, rb); + break; + +@@ -738,6 +779,7 @@ + state = connection_state(S_GOPHER_CSO_ERROR); + break; + ++ case GOPHER_INDEX: + case GOPHER_SOUND: + case GOPHER_PLUS_SOUND: + case GOPHER_PLUS_MOVIE: -- cgit v1.2.3