fixed issue where absolute unix paths were not sanitized

This commit is contained in:
The-EDev 2022-02-08 19:11:46 +03:00
parent 9f64a7b667
commit 155cf759eb
No known key found for this signature in database
GPG Key ID: 51C45DC0C413DCD9
2 changed files with 10 additions and 1 deletions

View File

@ -694,7 +694,15 @@ namespace crow
}
else if ((c == '/') || (c == '\\'))
{
checkForSpecialEntries = true;
//TODO(EDev): uncomment below once #332 is merged
if (/*CROW_UNLIKELY(*/i == 0/*)*/) //Prevent Unix Absolute Paths (Windows Absolute Paths are prevented with `(c == ':')`)
{
data[i] = replacement;
}
else
{
checkForSpecialEntries = true;
}
}
}
}

View File

@ -2473,6 +2473,7 @@ TEST_CASE("sanitize_filename")
CHECK(sanitize_filename("abc/COM9") == "abc/_");
CHECK(sanitize_filename("abc/COM") == "abc/COM");
CHECK(sanitize_filename("abc/CON") == "abc/_");
CHECK(sanitize_filename("/abc/") == "_abc/");
}
TEST_CASE("get_port")