summaryrefslogtreecommitdiffstats
path: root/network/elinks/patches/0002-gopher_index_queries.patch
blob: 662fd13a7f84a9468e38a671570eb993854d625b (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#######################################################################
# Fix for type 7 entities.
# dave@slackbuilds.org
#######################################################################
diff -Naur '--exclude=.git' bb/src/protocol/gopher/gopher.c cc/src/protocol/gopher/gopher.c
--- bb/src/protocol/gopher/gopher.c	2020-01-13 22:35:13.663935305 +0000
+++ cc/src/protocol/gopher/gopher.c	2020-01-13 23:16:00.053003768 +0000
@@ -197,7 +197,7 @@
 	command->length = strlen(command->source);
 }
 
-static struct connection_state init_gopher_index_cache_entry(struct connection *conn);
+/* static struct connection_state init_gopher_index_cache_entry(struct connection *conn); */
 
 static struct connection_state
 add_gopher_command(struct connection *conn, struct string *command,
@@ -205,7 +205,7 @@
 		   unsigned char *selector, int selectorlen)
 {
 	unsigned char *query;
-	int querylen;
+	int querylen = 0;
 
 	if (!init_string(command))
 		return connection_state(S_OUT_OF_MEM);
@@ -218,13 +218,14 @@
 		/* Exclude '?' */
 		if (query) selectorlen -= 1;
 		query = NULL;
-		querylen = 0;
-	} else {
-		query += 1;
+	} else if (entity == GOPHER_INDEX) {
+		/* fix query size to not include the search= part */
+		query += 8;
 		querylen = selector + selectorlen - query;
 		/* Exclude '?' */
-		selectorlen -= querylen + 1;
-		if (querylen >= 7 && !c_strncasecmp(query, "search=", 7)) {
+		/* fix selector length to fit with query */
+		selectorlen -= querylen + 8;
+		if (querylen >= 7 && !c_strncasecmp(query, "submit=", 7)) {
 			query	 += 7;
 			querylen -= 7;
 		}
@@ -233,9 +234,11 @@
 	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);
@@ -371,13 +374,14 @@
 add_gopher_search_field(struct string *buffer, const unsigned char *text,
 		const unsigned char *addr)
 {
+	/* Not *every* query is a search! */
 	add_format_to_string(buffer,
 		"<form action=\"%s\">"
 		"<table>"
 		"<td>            </td>"
 		"<td>%s:</td>"
-		"<td><input maxlength=\"256\" name=\"search\" value=\"\"></td>"
-		"<td><input type=submit value=\"Search\"></td>"
+		"<td><input maxlength=\"256\" name=\"submit\" value=\"\"></td>"
+		"<td><input type=submit value=\"Submit\"></td>"
 		"</table>"
 		"</form>",
 		addr, text);
@@ -662,6 +666,7 @@
 }
 
 /* Display a Gopher Index document. */
+/* Use the page that the gopher site sends us
 static struct connection_state
 init_gopher_index_cache_entry(struct connection *conn)
 {
@@ -674,9 +679,9 @@
 
 	where = get_uri_string(conn->uri, URI_PUBLIC);
 
-	/* TODO: Use different function when using UTF-8
+	 TODO: Use different function when using UTF-8
 	 * in terminal (decode_uri_for_display replaces
-	 * bytes of UTF-8 characters width '*'). */
+	 * bytes of UTF-8 characters width '*'). *
 	if (where) decode_uri_for_display(where);
 
 	add_format_to_string(&buffer,
@@ -695,7 +700,7 @@
 
 	mem_free_if(where);
 
-	/* FIXME: I think this needs a form or something */
+	* FIXME: I think this needs a form or something *
 
 	add_fragment(conn->cached, conn->from, buffer.source, buffer.length);
 	conn->from += buffer.length;
@@ -707,7 +712,7 @@
 		? connection_state(S_OK)
 		: connection_state(S_OUT_OF_MEM);
 }
-
+*/
 
 static void
 read_gopher_response_data(struct socket *socket, struct read_buffer *rb)