summaryrefslogtreecommitdiffstats
path: root/network/elinks/patches/0005-gopher_newlines_tabs_entity.patch
blob: f93b0d543140ccfa333027f09ddffca08db785e8 (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 '/'.
#####################################################################
diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c
--- a/src/protocol/gopher/gopher.c	2017-12-28 15:08:54.310546900 +0000
+++ b/src/protocol/gopher/gopher.c	2017-12-28 20:26:00.635193897 +0000
@@ -326,7 +326,7 @@
 
 	/* Get entity type, and selector string. */
 	/* Pick up gopher_entity */
-	if (selectorlen > 1 && selector[1] == '/') {
+	if (selectorlen > 1) {
 		entity = *selector++;
 		selectorlen--;
 	}
@@ -357,8 +357,7 @@
 		selectorlen++;
 	}
 
-	if (entity_info->type == '1')
-	{
+	if (entity_info->type == '1') {
 		if (strstr(selector, DIR) == selector)
 		{
 			*selector++;
@@ -402,9 +401,9 @@
 	gopher->entity = entity_info;
 	gopher->commandlen = command.length;
 
-	debug_log("439 gopher->entity: ", 0);
+	debug_log("404 gopher->entity: ", 0);
 	debug_log(gopher->entity, 1);
-	debug_log("437 command.source: ", 0);
+	debug_log("406 command.source: ", 0);
 	debug_log(command.source, 1);
 	memcpy(gopher->command, command.source, command.length);
 	done_string(&command);
@@ -486,6 +485,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');
@@ -495,6 +495,7 @@
 	if (*name) {
 		selector = strchr(name, ASCII_TAB);
 		if (selector) {
+			link = 1;
 			/* Terminate name */
 			*selector++ = '\0';
 
@@ -565,7 +566,7 @@
 	switch (entity) {
 	case GOPHER_WWW:
 		/* Gopher pointer to W3 */
-		if (selector) {
+		if (selector && link == 1) {
 			add_gopher_link(buffer, name, selector);
 			break;
 		}
@@ -617,7 +618,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 {
@@ -639,6 +641,12 @@
 	for (; datalen > 1; data++, datalen--)
 		if (data[0] == ASCII_CR && data[1] == ASCII_LF)
 			return data + 2;
+		else
+			if(data[0] == ASCII_CR)
+				return data + 2;
+		else
+			if(data[0] == ASCII_LF)
+				return data + 2;
 
 	return NULL;
 }