aboutsummaryrefslogtreecommitdiff
path: root/network/elinks/patches/0001-gopher_html_links.patch
blob: c9ab73856da762d02daf8e0564bc4c7bf83387dc (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
################################################################
# There is a problem that html links that contain URL:htpp://...
# aren't being followed. This fixes that issue and also chtml.
# Normally those kind of links go to a redirect page that the
# server generates, which then sends you on your way.
# dave@dawoodfall.net
###############################################################
diff -Naur a/src/protocol/gopher/gopher.c b/src/protocol/gopher/gopher.c
--- a/src/protocol/gopher/gopher.c	2013-12-18 15:38:57.000000000 +0000
+++ b/src/protocol/gopher/gopher.c	2017-11-15 23:10:19.758394411 +0000
@@ -277,6 +277,10 @@
 	struct string command;
 	enum gopher_entity entity = DEFAULT_GOPHER_ENTITY;
 	unsigned char *selector = conn->uri->data;
+	unsigned char *URI = "hURI%3";
+	unsigned char *URL = "hURL%3";
+	unsigned char *CURI = "HURI%3";
+	unsigned char *CURL = "HURL%3";
 	int selectorlen = conn->uri->datalen;
 	struct gopher_entity_info *entity_info;
 	size_t size;
@@ -288,6 +292,18 @@
 		selectorlen--;
 	}
 
+	if(strstr(selector, URL) != NULL || strstr(selector, URI) != NULL) {
+		entity = GOPHER_HTML;
+		*selector++;
+		selectorlen--;
+	}
+
+	if(strstr(selector, CURL) != NULL || strstr(selector, CURI) != NULL) {
+		entity = GOPHER_CHTML;
+		*selector++;
+		selectorlen--;
+	}
+
 	/* This is probably a hack. It serves as a work around when no entity is
 	 * available in the Gopher URI. Instead of segfaulting later the content
 	 * will be served as application/octet-stream. However, it could