diff options
Diffstat (limited to 'init/util.c')
-rwxr-xr-x | init/util.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/init/util.c b/init/util.c index 918bc05..76af9e5 100755 --- a/init/util.c +++ b/init/util.c @@ -305,14 +305,27 @@ int mkdir_recursive(const char *pathname, mode_t mode) return 0; } +/* + * replaces any unacceptable characters with '_', the + * length of the resulting string is equal to the input string + */ void sanitize(char *s) { + const char* accept = + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + "_-."; + if (!s) return; - while (isalnum(*s)) - s++; - *s = 0; + + for (; *s; s++) { + s += strspn(s, accept); + if (*s) *s = '_'; + } } + void make_link(const char *oldpath, const char *newpath) { int ret; |