mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds 'expandKeepOriginal' method to macro expansion class
This commit is contained in:
parent
c425b24ffb
commit
4bf7f7a44c
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user