mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
parser: Improves the include error when the file does not exist
This commit is contained in:
parent
8b4f1bc46c
commit
4643501507
@ -397,6 +397,11 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
||||
{CONFIG_INCLUDE}[ ]{CONFIG_VALUE_PATH} {
|
||||
const char *file = strchr(yytext, ' ') + 1;
|
||||
std::string fi = modsecurity::utils::find_resource(file, driver.ref.back());
|
||||
if (fi.empty() == true) {
|
||||
BEGIN(INITIAL);
|
||||
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
||||
throw p::syntax_error(*driver.loc.back(), "");
|
||||
}
|
||||
for (auto& s: modsecurity::utils::expandEnv(fi, 0)) {
|
||||
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
||||
yyin = fopen(f.c_str(), "r" );
|
||||
@ -416,6 +421,11 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
||||
char *f = strdup(file + 1);
|
||||
f[strlen(f)-1] = '\0';
|
||||
std::string fi = modsecurity::utils::find_resource(f, driver.ref.back());
|
||||
if (fi.empty() == true) {
|
||||
BEGIN(INITIAL);
|
||||
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
||||
throw p::syntax_error(*driver.loc.back(), "");
|
||||
}
|
||||
for (auto& s: modsecurity::utils::expandEnv(fi, 0)) {
|
||||
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
||||
yyin = fopen(f.c_str(), "r" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user