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
|
/* mailto.c
* mailto:// processing
* (c) 2002 Mikulas Patocka
* This file is a part of the Links program, released under GPL.
*/
#include "links.h"
static void prog_func(struct terminal *term, struct list_head *list, unsigned char *param, unsigned char *name)
{
unsigned char *prog, *cmd;
if (!(prog = get_prog(list)) || !*prog) {
msg_box(term, NULL, TEXT_(T_NO_PROGRAM), AL_CENTER | AL_EXTD_TEXT, TEXT_(T_NO_PROGRAM_SPECIFIED_FOR), " ", name, ".", NULL, NULL, 1, TEXT_(T_CANCEL), NULL, B_ENTER | B_ESC);
return;
}
if ((cmd = subst_file(prog, param, 0))) {
exec_on_terminal(term, cmd, "", 1);
mem_free(cmd);
}
}
void mailto_func(struct session *ses, unsigned char *url)
{
unsigned char *user, *host, *m;
int f = 1;
if (!(user = get_user_name(url))) goto fail;
if (!(host = get_host_name(url))) goto fail1;
m = mem_alloc(strlen(user) + strlen(host) + 2);
f = 0;
strcpy(m, user);
strcat(m, "@");
strcat(m, host);
check_shell_security(&m);
prog_func(ses->term, &mailto_prog, m, TEXT_(T_MAIL));
mem_free(m);
mem_free(host);
fail1:
mem_free(user);
fail:
if (f) msg_box(ses->term, NULL, TEXT_(T_BAD_URL_SYNTAX), AL_CENTER, TEXT_(T_BAD_MAILTO_URL), NULL, 1, TEXT_(T_CANCEL), NULL, B_ENTER | B_ESC);
}
static void tn_func(struct session *ses, unsigned char *url, struct list_head *prog, unsigned char *t1, unsigned char *t2)
{
unsigned char *m;
unsigned char *h, *p;
int hl, pl;
unsigned char *hh, *pp = NULL /* against warning */;
int f = 1;
if (parse_url(url, NULL, NULL, NULL, NULL, NULL, &h, &hl, &p, &pl, NULL, NULL, NULL) || !hl) goto fail;
if (!(hh = memacpy(h, hl))) goto fail;
if (pl && !(pp = memacpy(p, pl))) goto fail1;
check_shell_security(&hh);
if (pl) check_shell_security(&pp);
m = mem_alloc(strlen(hh) + (pl ? strlen(pp) : 0) + 2);
f = 0;
strcpy(m, hh);
if (pl) {
strcat(m, " ");
strcat(m, pp);
m[hl + 1 + pl] = 0;
}
prog_func(ses->term, prog, m, t1);
mem_free(m);
if (pl) mem_free(pp);
fail1:
mem_free(hh);
fail:
if (f) msg_box(ses->term, NULL, TEXT_(T_BAD_URL_SYNTAX), AL_CENTER, t2, NULL, 1, TEXT_(T_CANCEL), NULL, B_ENTER | B_ESC);
}
void telnet_func(struct session *ses, unsigned char *url)
{
tn_func(ses, url, &telnet_prog, TEXT_(T_TELNET), TEXT_(T_BAD_TELNET_URL));
}
void tn3270_func(struct session *ses, unsigned char *url)
{
tn_func(ses, url, &tn3270_prog, TEXT_(T_TN3270), TEXT_(T_BAD_TN3270_URL));
}
void magnet_func(struct session *ses, unsigned char *url)
{
unsigned char *escaped_url = escape_path(url);
prog_func(ses->term, &magnet_prog, escaped_url, TEXT_(T_MAGNET));
mem_free(escaped_url);
}
void mms_func(struct session *ses, unsigned char *url)
{
if (check_shell_url(url)) {
msg_box(ses->term, NULL, TEXT_(T_BAD_URL_SYNTAX), AL_CENTER, TEXT_(T_MMS_URL_CONTAINS_INACCEPTABLE_CHARACTERS), NULL, 1, TEXT_(T_CANCEL), NULL, B_ENTER | B_ESC);
return;
}
prog_func(ses->term, &mms_prog, url, TEXT_(T_MMS));
}
|