aboutsummaryrefslogtreecommitdiffstats
path: root/debian/patches/250_schemebug.patch
blob: a5e491e1624ef4d9fcd3a7459c3422f40d81bba8 (plain) (blame)
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
Subject: Define schemeNumToName() to fix scheme bug
From: AIDA Shinra <shinra@j10n.org>
Origin: http://www.j10n.org/files/w3m-cvs-1.1055-schemebug.patch
    
    Patch from [w3m-dev:04470] on 2013-10-14.

diff --git a/url.c b/url.c
index cbb4aab..d7b1d6e 100644
--- a/url.c
+++ b/url.c
@@ -121,6 +121,7 @@ static struct table2 DefaultGuess[] = {
 };
 
 static void add_index_file(ParsedURL *pu, URLFile *uf);
+static char * schemeNumToName(int scheme);
 
 /* #define HTTP_DEFAULT_FILE    "/index.html" */
 
@@ -1285,6 +1286,18 @@ getURLScheme(char **url)
 }
 
 static char *
+schemeNumToName(int scheme)
+{
+    int i;
+
+    for (i = 0; schemetable[i].cmdname != NULL; i++) {
+	if (schemetable[i].cmd == scheme)
+	    return schemetable[i].cmdname;
+    }
+    return NULL;
+}
+
+static char *
 otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
 {
     Str s = Strnew();
@@ -1616,7 +1629,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
 	    pu->host != NULL && !check_no_proxy(pu->host)) {
 	    hr->flag |= HR_FLAG_PROXY;
 	    sock = openSocket(FTP_proxy_parsed.host,
-			      schemetable[FTP_proxy_parsed.scheme].cmdname,
+			      schemeNumToName(FTP_proxy_parsed.scheme),
 			      FTP_proxy_parsed.port);
 	    if (sock < 0)
 		return uf;
@@ -1658,15 +1671,15 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
 	    }
 	    else if (pu->scheme == SCM_HTTPS) {
 		sock = openSocket(HTTPS_proxy_parsed.host,
-				  schemetable[HTTPS_proxy_parsed.scheme].
-				  cmdname, HTTPS_proxy_parsed.port);
+				  schemeNumToName(HTTPS_proxy_parsed.scheme),
+				  HTTPS_proxy_parsed.port);
 		sslh = NULL;
 	    }
 	    else {
 #endif				/* USE_SSL */
 		sock = openSocket(HTTP_proxy_parsed.host,
-				  schemetable[HTTP_proxy_parsed.scheme].
-				  cmdname, HTTP_proxy_parsed.port);
+				  schemeNumToName(HTTP_proxy_parsed.scheme),
+				  HTTP_proxy_parsed.port);
 #ifdef USE_SSL
 		sslh = NULL;
 	    }
@@ -1698,8 +1711,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
 	    }
 	}
 	else {
-	    sock = openSocket(pu->host,
-			      schemetable[pu->scheme].cmdname, pu->port);
+	    sock = openSocket(pu->host, schemeNumToName(pu->scheme), pu->port);
 	    if (sock < 0) {
 		*status = HTST_MISSING;
 		return uf;
@@ -1763,7 +1775,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
 	    pu->host != NULL && !check_no_proxy(pu->host)) {
 	    hr->flag |= HR_FLAG_PROXY;
 	    sock = openSocket(GOPHER_proxy_parsed.host,
-			      schemetable[GOPHER_proxy_parsed.scheme].cmdname,
+			      schemeNumToName(GOPHER_proxy_parsed.scheme),
 			      GOPHER_proxy_parsed.port);
 	    if (sock < 0)
 		return uf;
@@ -1771,8 +1783,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current,
 	    tmp = HTTPrequest(pu, current, hr, extra_header);
 	}
 	else {
-	    sock = openSocket(pu->host,
-			      schemetable[pu->scheme].cmdname, pu->port);
+	    sock = openSocket(pu->host, schemeNumToName(pu->scheme), pu->port);
 	    if (sock < 0)
 		return uf;
 	    if (pu->file == NULL)