]> git.cameronkatri.com Git - cgit.git/blobdiff - cache.c
Use tables and css to create the diffstat graph, fix scaling
[cgit.git] / cache.c
diff --git a/cache.c b/cache.c
index 1ff1251dfb856e4e8ad2a9a15c502b13ada00f53..8df7c2677bc24f6980888f95523931b7538bd74a 100644 (file)
--- a/cache.c
+++ b/cache.c
 
 const int NOLOCK = -1;
 
+char *cache_safe_filename(const char *unsafe)
+{
+       static char buf[PATH_MAX];
+       char *s = buf;
+       char c;
+
+       while(unsafe && (c = *unsafe++) != 0) {
+               if (c == '/' || c == ' ' || c == '&' || c == '|' || 
+                   c == '>' || c == '<' || c == '.')
+                       c = '_';
+               *s++ = c;
+       }
+       *s = '\0';
+       return buf;
+}
+
 int cache_exist(struct cacheitem *item)
 {
        if (stat(item->name, &item->st)) {