summaryrefslogtreecommitdiffstats
path: root/network/elinks/patches/0005-gopher_newlines_tabs_entity.patch
blob: f27b655cc61299850fcb8c4de06cb7066bc5905e (plain)
#####################################################################
# Some fixes for having line feeds in text without a carriage return.
# Make sure that only lines with tabs are treated as links.
# Support links that don't begin with a '/'.
# 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:43:40.148408539 +0000
+++ b/src/protocol/gopher/gopher.c	2020-01-08 05:43:26.357005028 +0000
@@ -322,7 +322,7 @@
 
 	/* Get entity type, and selector string. */
 	/* Pick up gopher_entity */
-	if (selectorlen > 1 && selector[1] == '/') {
+	if (selectorlen > 1) {
 		entity = *selector++;
 		selectorlen--;
 	}
@@ -472,6 +472,7 @@
 	unsigned char *host = NULL;
 	unsigned char *port = NULL;
 	enum gopher_entity entity = *name++;
+	int link = 0;
 
 	if (!entity) {
 		add_char_to_string(buffer, '\n');
@@ -481,6 +482,7 @@
 	if (*name) {
 		selector = strchr(name, ASCII_TAB);
 		if (selector) {
+			link = 1;
 			/* Terminate name */
 			*selector++ = '\0';
 
@@ -551,7 +553,7 @@
 	switch (entity) {
 	case GOPHER_WWW:
 		/* Gopher pointer to W3 */
-		if (selector) {
+		if (selector && link == 1) {
 			add_gopher_link(buffer, name, selector);
 			break;
 		}
@@ -603,7 +605,8 @@
 
 		} else if (address.length > 0
 			   && strlcmp(address.source, address.length - 1,
-				      "gopher://error.host:1/", -1)) {
+				      "gopher://error.host:1/", -1)
+				 && link == 1) {
 			add_gopher_link(buffer, name, address.source);
 
 		} else {
@@ -623,7 +626,7 @@
 get_gopher_line_end(unsigned char *data, int datalen)
 {
 	for (; datalen > 1; data++, datalen--)
-		if (data[0] == ASCII_CR && data[1] == ASCII_LF)
+		if (data[0] == ASCII_CR || data[0] == ASCII_LF)
 			return data + 2;
 
 	return NULL;