Add mg_remove_double_dots(), hide mg_http_upload()

This commit is contained in:
Sergey Lyubka committed 2022-06-30 20:27:43 +01:00
1 parent c5751b0bd3
commit 56412193e7
6 files changed
+69 -95

No files matched your search

+21 -1
View File
@@ -196,7 +196,6 @@ void mg_unhex(const char *buf, size_t len, unsigned char *to) {
}
}
uint64_t mg_tou64(struct mg_str str) {
uint64_t result = 0;
size_t i = 0;
@@ -222,3 +221,24 @@ int64_t mg_to64(struct mg_str str) {
}
return result * neg;
}
char *mg_remove_double_dots(char *s) {
char *p = s;
while (*s != '\0') {
*p++ = *s++;
if (s[-1] == '/' || s[-1] == '\\') {
while (s[0] != '\0') {
if (s[0] == '/' || s[0] == '\\') {
s++;
} else if (s[0] == '.' && s[1] == '.' &&
(s[2] == '/' || s[2] == '\\')) {
s += 2;
} else {
break;
}
}
}
}
*p = '\0';
return s;
}