Unidiff1 files changed, 16 insertions, 0 deletions
|
diff --git a/cache.c b/cache.c index 1ff1251..8df7c26 100644 --- a/ cache.c+++ b/ cache.c |
|
@@ -5,16 +5,32 @@ |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | const int NOLOCK = -1; |
11 | const int NOLOCK = -1; |
12 | |
12 | |
| |
13 | char *cache_safe_filename(const char *unsafe) |
| |
14 | { |
| |
15 | static char buf[PATH_MAX]; |
| |
16 | char *s = buf; |
| |
17 | char c; |
| |
18 | |
| |
19 | while(unsafe && (c = *unsafe++) != 0) { |
| |
20 | if (c == '/' || c == ' ' || c == '&' || c == '|' || |
| |
21 | c == '>' || c == '<' || c == '.') |
| |
22 | c = '_'; |
| |
23 | *s++ = c; |
| |
24 | } |
| |
25 | *s = '\0'; |
| |
26 | return buf; |
| |
27 | } |
| |
28 | |
13 | int cache_exist(struct cacheitem *item) |
29 | int cache_exist(struct cacheitem *item) |
14 | { |
30 | { |
15 | if (stat(item->name, &item->st)) { |
31 | if (stat(item->name, &item->st)) { |
16 | item->st.st_mtime = 0; |
32 | item->st.st_mtime = 0; |
17 | return 0; |
33 | return 0; |
18 | } |
34 | } |
19 | return 1; |
35 | return 1; |
20 | } |
36 | } |
|