From 6d17b36605292a0eda148178677f72819c80b6fe Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 24 Feb 2022 11:57:25 +0100 Subject: ox: expand file and check for existance before trying to announce Output before: ``` 11:00:00 - Annonuce OpenPGP Key for OX ~/test/testuser.pub.gpg ... ``` After: ``` 11:00:00 - Annonuce OpenPGP Key for OX /home/user/test/testuser.pub.gpg ... ``` Now we expand the path so that we can check for `~` properly. And test if the file is actually a normal file. --- src/command/cmd_funcs.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 4b79b145..0219b61f 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -7613,7 +7613,22 @@ cmd_ox(ProfWin* window, const char* const command, gchar** args) return TRUE; } else if (g_strcmp0(args[0], "announce") == 0) { if (args[1]) { - ox_announce_public_key(args[1]); + gchar* filename = get_expanded_path(args[1]); + + if (access(filename, R_OK) != 0) { + cons_show_error("File not found: %s", filename); + g_free(filename); + return TRUE; + } + + if (!is_regular_file(filename)) { + cons_show_error("Not a file: %s", filename); + g_free(filename); + return TRUE; + } + + ox_announce_public_key(filename); + free(filename); } else { cons_show("Filename is required"); } -- cgit 1.4.1-2-gfad0 /directories.go?h=0.1.3&id=c047b068c279ef49ae8e95b180d7b7fe0ec5b815'>diff stats
path: root/widgets/directories.go
blob: 11fe2d64e97224059c878d382724335ee9ba9345 (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
96
97
98
99
100
101
102
103
104
105