mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-15 17:12:14 +03:00
Refactor Regex classes further
This commit changes Regex interface rather dramatically. Most importantly, RegexMatch class now contains a list of matched groups, with group(0) being entire match, group(1) - first capturing group, and so on. Secondly, searchAll now returns a list of RegexMatch objects instead of reversed flattened list of groups from all matches.
This commit is contained in:
@@ -64,18 +64,16 @@ void json2bin(std::string *str) {
|
||||
|
||||
while (re.search(*str, &match)) {
|
||||
unsigned int p;
|
||||
std::string toBeReplaced = match.str();
|
||||
toBeReplaced.erase(0, 2);
|
||||
sscanf(toBeReplaced.c_str(), "%x", &p);
|
||||
replaceAll(str, match.str(), p);
|
||||
std::string toBeReplaced = match.group(0).string;
|
||||
sscanf(toBeReplaced.substr(2).c_str(), "%x", &p);
|
||||
replaceAll(str, toBeReplaced, p);
|
||||
}
|
||||
|
||||
while (re2.search(*str, &match)) {
|
||||
unsigned int p;
|
||||
std::string toBeReplaced = match.str();
|
||||
toBeReplaced.erase(0, 2);
|
||||
sscanf(toBeReplaced.c_str(), "%4x", &p);
|
||||
replaceAll(str, match.str(), p);
|
||||
std::string toBeReplaced = match.group(0).string;
|
||||
sscanf(toBeReplaced.substr(2).c_str(), "%4x", &p);
|
||||
replaceAll(str, toBeReplaced, p);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user