From dd634581ab75b056993a358414a7c05936879fd4 Mon Sep 17 00:00:00 2001 From: David Woodfall Date: Mon, 18 Dec 2017 10:35:57 +0000 Subject: network/elinks: Patched for remote directory gopher links. Signed-off-by: David Spencer --- network/elinks/0001-gopher_html_links.patch | 39 ++++++++ network/elinks/0002-gopher_index_queries.patch | 119 +++++++++++++++++++++++ network/elinks/0003-gopher_directory_links.patch | 60 ++++++++++++ network/elinks/elinks.SlackBuild | 9 +- network/elinks/gopher_html_links.patch | 39 -------- network/elinks/gopher_index_queries.patch | 119 ----------------------- 6 files changed, 224 insertions(+), 161 deletions(-) create mode 100644 network/elinks/0001-gopher_html_links.patch create mode 100644 network/elinks/0002-gopher_index_queries.patch create mode 100644 network/elinks/0003-gopher_directory_links.patch delete mode 100644 network/elinks/gopher_html_links.patch delete mode 100644 network/elinks/gopher_index_queries.patch (limited to 'network/elinks') diff --git a/network/elinks/0001-gopher_html_links.patch b/network/elinks/0001-gopher_html_links.patch new file mode 100644 index 0000000000..4e34e9cdbc --- /dev/null +++ b/network/elinks/0001-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/0002-gopher_index_queries.patch b/network/elinks/0002-gopher_index_queries.patch new file mode 100644 index 0000000000..e281e4cc44 --- /dev/null +++ b/network/elinks/0002-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 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,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: diff --git a/network/elinks/0003-gopher_directory_links.patch b/network/elinks/0003-gopher_directory_links.patch new file mode 100644 index 0000000000..6185af21b6 --- /dev/null +++ b/network/elinks/0003-gopher_directory_links.patch @@ -0,0 +1,60 @@ +####################################################################### +# elinks does not follow links to directories on other servers +# properly. This adds a '/' before the '1' at the start of a link and +# removes any trailing 1. +####################################################################### +diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c +--- a/src/protocol/gopher/gopher.c 2017-12-17 01:54:27.941645180 +0000 ++++ b/src/protocol/gopher/gopher.c 2017-12-17 21:52:05.072454433 +0000 +@@ -317,6 +317,9 @@ + unsigned char *URL = "hURL%3"; + unsigned char *CURI = "HURI%3"; + unsigned char *CURL = "HURL%3"; ++ unsigned char *DIR = "1"; ++ unsigned char *SLASHDIR = "/1"; ++ unsigned char *SLASHPOS; + int selectorlen = conn->uri->datalen; + struct gopher_entity_info *entity_info; + size_t size; +@@ -354,6 +357,26 @@ + selectorlen++; + } + ++ if (entity_info->type == '1') ++ { ++ if (strstr(selector, DIR) == selector) ++ { ++ *selector++; ++ selectorlen--; ++ } ++ else ++ { ++ SLASHPOS = strstr(selector, SLASHDIR); ++ if (SLASHPOS != NULL) ++ { ++ if (strlen(SLASHPOS) == 2) ++ { ++ selectorlen--; ++ } ++ } ++ } ++ } ++ + state = add_gopher_command(conn, &command, entity, selector, selectorlen); + if (!is_in_state(state, S_CONN)) + return state; +@@ -379,10 +402,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); ++ debug_log("439 gopher->entity: ", 0); ++ debug_log(gopher->entity, 1); ++ debug_log("437 command.source: ", 0); ++ debug_log(command.source, 1); + memcpy(gopher->command, command.source, command.length); + done_string(&command); + diff --git a/network/elinks/elinks.SlackBuild b/network/elinks/elinks.SlackBuild index 24505e81ff..21e907e863 100644 --- a/network/elinks/elinks.SlackBuild +++ b/network/elinks/elinks.SlackBuild @@ -26,7 +26,7 @@ PRGNAM=elinks VERSION=${VERSION:-git20131231} -BUILD=${BUILD:-6} +BUILD=${BUILD:-7} TAG=${TAG:-_SBo} if [ -z "$ARCH" ]; then @@ -72,10 +72,13 @@ find -L . \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; # Next patch fixes URL: html links -patch --verbose -p1 < $CWD/gopher_html_links.patch +patch --verbose -p1 < $CWD/0001-gopher_html_links.patch # Next patch fixes index queries -patch --verbose -p1 < $CWD/gopher_index_queries.patch +patch --verbose -p1 < $CWD/0002-gopher_index_queries.patch + +# Next patch fixes remote directory links +patch --verbose -p1 < $CWD/0003-gopher_directory_links.patch [ -n "$NOMOUSE" ] && mouse="--disable-mouse" [ -n "$NOGPM" ] && gpm="--without-gpm" diff --git a/network/elinks/gopher_html_links.patch b/network/elinks/gopher_html_links.patch deleted file mode 100644 index 4e34e9cdbc..0000000000 --- a/network/elinks/gopher_html_links.patch +++ /dev/null @@ -1,39 +0,0 @@ -################################################################ -# 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 deleted file mode 100644 index 17d2ac4b3e..0000000000 --- a/network/elinks/gopher_index_queries.patch +++ /dev/null @@ -1,119 +0,0 @@ -####################################################################### -# 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