mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-31 13:00:49 +00:00
cleanup 'str' API
This commit is contained in:
1 parent
6c7672f4af
commit
3c531897b6
20 files changed
+350
-400
No files matched your search
+12
@@ -106,6 +106,18 @@ int mg_check_ip_acl(struct mg_str acl, struct mg_addr *remote_ip) {
|
||||
return allowed == '+';
|
||||
}
|
||||
|
||||
bool mg_path_is_sane(const struct mg_str path) {
|
||||
const char *s = path.buf;
|
||||
size_t n = path.len;
|
||||
if (path.buf[0] == '.' && path.buf[1] == '.') return false; // Starts with ..
|
||||
for (; s[0] != '\0' && n > 0; s++, n--) {
|
||||
if ((s[0] == '/' || s[0] == '\\') && n >= 2) { // Subdir?
|
||||
if (s[1] == '.' && s[2] == '.') return false; // Starts with ..
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if MG_ENABLE_CUSTOM_MILLIS
|
||||
#else
|
||||
uint64_t mg_millis(void) {
|
||||
|
||||
Reference in new issue
Block a user