summaryrefslogtreecommitdiff
path: root/network/elinks/0005-gopher_newlines_tabs_entity.patch
blob: f93b0d543140ccfa333027f09ddffca08db785e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#####################################################################
# 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;
 }