Adds 'expandKeepOriginal' method to macro expansion class

This commit is contained in:
Felipe Zimmerle 2015-09-16 11:22:57 -03:00
parent c425b24ffb
commit 4bf7f7a44c
2 changed files with 15 additions and 1 deletions

View File

@ -20,13 +20,26 @@ namespace ModSecurity {
MacroExpansion::MacroExpansion() { }
std::string MacroExpansion::expandKeepOriginal(const std::string& input,
Assay *assay) {
std::string a = MacroExpansion::expand(input, assay);
if (a != input) {
return "\"" + a + "\" (Was: " + input + ")";
}
return input;
}
std::string MacroExpansion::expand(const std::string& input, Assay *assay) {
std::string res(input);
size_t pos = res.find("%{");
while (pos != std::string::npos) {
size_t start = pos;
size_t end = res.find("}%");
size_t end = res.find("}");
if (end == std::string::npos) {
return res;
}

View File

@ -32,6 +32,7 @@ class MacroExpansion {
MacroExpansion();
static std::string expand(const std::string& input, Assay *assay);
static std::string expandKeepOriginal(const std::string& input, Assay *assay);
};