summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Van Doorn <vandoorn.nick@gmail.com>2019-06-16 20:48:07 -0700
committerNick Van Doorn <vandoorn.nick@gmail.com>2019-06-16 20:48:07 -0700
commitca2ca5620d7e79730ef95c004e8543a97befa5ac (patch)
treeecb5eabaa12f58d62b6dc1e08ffbf6a22d218c84
parent00dad6a75d1eebd853f294425ff588743b62368c (diff)
Try to sanitize paths
-rw-r--r--core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/core.c b/core.c
index db9a06d..28930fd 100644
--- a/core.c
+++ b/core.c
@@ -15,6 +15,14 @@ void printInfo(const char *s) {
printf("INFO: %s\n", s);
}
+char* replaceChar(char* str, char find, char replace) {
+ char *currentPos = strchr(str,find);
+ while(currentPos) {
+ *currentPos = replace;
+ currentPos = strchr(currentPos, find);
+ }
+ return str;
+}
void gitrolex_parseArgs(struct State_t *s, int argc, const char *argv[]) {
const char *task;
@@ -45,6 +53,9 @@ void gitrolex_parseArgs(struct State_t *s, int argc, const char *argv[]) {
}
s->task = TRACK;
strcpy(s->taskArgs, argv[2]);
+ // lame attempt at path sanitization
+ replaceChar(s->taskArgs, '/', '-');
+ replaceChar(s->taskArgs, '$', '-');
}
}