aboutsummaryrefslogtreecommitdiffstats
path: root/src/path.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-14 05:26:32 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-14 05:26:32 +0000
commit2a24a94ba76a0cca004d5b7b09144ae1ac14aa26 (patch)
treec324e6dfde7a8c43fbd3ee54fe5ad74b9a30e4ad /src/path.c
parentba1d3302e2a96d20a77f70b1dd263b2a344432ee (diff)
downloadmpd-2a24a94ba76a0cca004d5b7b09144ae1ac14aa26.tar.gz
mpd-2a24a94ba76a0cca004d5b7b09144ae1ac14aa26.tar.xz
mpd-2a24a94ba76a0cca004d5b7b09144ae1ac14aa26.zip
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
Diffstat (limited to '')
-rw-r--r--src/path.c39
1 files changed, 39 insertions, 0 deletions
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 <stdlib.h>
#include <string.h>
@@ -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);
+}