From 2a24a94ba76a0cca004d5b7b09144ae1ac14aa26 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Wed, 14 Apr 2004 05:26:32 +0000 Subject: ok, finished incremental update! now just need to polish up a few things with update git-svn-id: https://svn.musicpd.org/mpd/trunk@745 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/path.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/path.c') diff --git a/src/path.c b/src/path.c index e9031100d..71bacd7b3 100644 --- a/src/path.c +++ b/src/path.c @@ -20,6 +20,7 @@ #include "log.h" #include "charConv.h" #include "conf.h" +#include "utf8.h" #include #include @@ -202,3 +203,41 @@ char * parentPath(char * path) { return parentPath; } + +char * sanitizePathDup(char * path) { + int len = strlen(path)+1; + char * ret = malloc(len); + char * cp = ret; + + memset(ret,0,len); + + len = 0; + + /* illeminate more than one '/' in a row, like "///" */ + while(*path) { + while(*path=='/') path++; + if(*path=='.') { + /* we dont want to have hidden directoires, or '.' or + ".." in our path */ + free(ret); + return NULL; + } + while(*path && *path!='/') { + *(cp++) = *(path++); + len++; + } + if(*path=='/') { + *(cp++) = *(path++); + len++; + } + } + + if(len && ret[len-1]=='/') { + len--; + ret[len] = '\0'; + } + + printf("sanitized: %s\n", ret); + + return realloc(ret,len+1); +} -- cgit v1.2.3