mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 19:47:47 +03:00
Adds possibility to use include with wildcards and env vars
This commit is contained in:
18
src/utils.cc
18
src/utils.cc
@@ -19,6 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -1022,5 +1023,22 @@ std::string toHexIfNeeded(const std::string &str) {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> expandEnv(const std::string& var, int flags)
|
||||
{
|
||||
std::vector<std::string> vars;
|
||||
|
||||
wordexp_t p;
|
||||
if (wordexp(var.c_str(), &p, flags) == false) {
|
||||
if (p.we_wordc) {
|
||||
for (char** exp = p.we_wordv; *exp; ++exp) {
|
||||
vars.push_back(exp[0]);
|
||||
}
|
||||
}
|
||||
wordfree(&p);
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ModSecurity
|
||||
|
||||
|
Reference in New Issue
Block a user