summaryrefslogtreecommitdiffstats
path: root/network/elinks/patches/0005-gopher_newlines_tabs_entity.patch
blob: b255fb4f982d5d0ccac327510dd3613a662e8c82 (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
#####################################################################
# Fix line feeds without carriage returns.
# Make sure that only lines with tabs are treated as links.
# Support links that don't begin with a '/'.
# dave@slackbuilds.org
#####################################################################
diff -Naur -x .git bb/src/protocol/gopher/gopher.c cc/src/protocol/gopher/gopher.c
--- bb/src/protocol/gopher/gopher.c	2020-01-14 03:19:39.956296190 +0000
+++ cc/src/protocol/gopher/gopher.c	2020-01-14 03:20:05.295045232 +0000
@@ -290,7 +290,7 @@
 
 	/* Get entity type, and selector string. */
 	/* Pick up gopher_entity */
-	if (selectorlen > 1 && selector[1] == '/') {
+	if (selectorlen > 1) {
 		entity = *selector++;
 		selectorlen--;
 	}
@@ -333,6 +333,18 @@
 		}
 	}
 
+	if (entity_info->type == '1') {
+		if (strchr(selector, '1') == (char *) selector) {
+			selector++;
+			selectorlen--;
+		}
+		else {
+			if ((char *) selector  == "/1") {
+				selectorlen--;
+			}
+		}
+	}
+
 	state = add_gopher_command(conn, &command, entity, selector, selectorlen);
 	if (!is_in_state(state, S_CONN))
 		return state;
@@ -570,7 +582,8 @@
 
 		} else if (address.length > 0
 			   && strlcmp(address.source, address.length - 1,
-				      "gopher://error.host:1/", -1)) {
+				      "gopher://error.host:1/", -1)
+				 && selector) {
 			add_gopher_link(buffer, name, address.source);
 
 		} else {
@@ -590,7 +603,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;