mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Coding style fixes
This commit is contained in:
@@ -117,7 +117,8 @@ int JSON::addArgument(const std::string& value) {
|
||||
std::string path;
|
||||
|
||||
for (size_t i = 0; i < m_containers.size(); i++) {
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(m_containers[i]);
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(
|
||||
m_containers[i]);
|
||||
path = path + m_containers[i]->m_name;
|
||||
if (a != NULL) {
|
||||
path = path + ".array_" + std::to_string(a->m_elementCounter);
|
||||
@@ -126,7 +127,8 @@ int JSON::addArgument(const std::string& value) {
|
||||
}
|
||||
}
|
||||
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(m_containers.back());
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(
|
||||
m_containers.back());
|
||||
if (a) {
|
||||
a->m_elementCounter++;
|
||||
} else {
|
||||
@@ -212,7 +214,8 @@ int JSON::yajl_number(void *ctx, const char *value, size_t length) {
|
||||
int JSON::yajl_start_array(void *ctx) {
|
||||
JSON *tthis = reinterpret_cast<JSON *>(ctx);
|
||||
std::string name = tthis->getCurrentKey();
|
||||
tthis->m_containers.push_back((JSONContainer *)new JSONContainerArray(name));
|
||||
tthis->m_containers.push_back(
|
||||
reinterpret_cast<JSONContainer *>(new JSONContainerArray(name)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -223,7 +226,8 @@ int JSON::yajl_end_array(void *ctx) {
|
||||
tthis->m_containers.pop_back();
|
||||
delete a;
|
||||
if (tthis->m_containers.size() > 0) {
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(tthis->m_containers.back());
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(
|
||||
tthis->m_containers.back());
|
||||
if (a) {
|
||||
a->m_elementCounter++;
|
||||
}
|
||||
@@ -236,7 +240,8 @@ int JSON::yajl_end_array(void *ctx) {
|
||||
int JSON::yajl_start_map(void *ctx) {
|
||||
JSON *tthis = reinterpret_cast<JSON *>(ctx);
|
||||
std::string name(tthis->getCurrentKey());
|
||||
tthis->m_containers.push_back((JSONContainer *)new JSONContainerMap(name));
|
||||
tthis->m_containers.push_back(
|
||||
reinterpret_cast<JSONContainer *>(new JSONContainerMap(name)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -252,7 +257,8 @@ int JSON::yajl_end_map(void *ctx) {
|
||||
delete a;
|
||||
|
||||
if (tthis->m_containers.size() > 0) {
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(tthis->m_containers.back());
|
||||
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(
|
||||
tthis->m_containers.back());
|
||||
if (a) {
|
||||
a->m_elementCounter++;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "modsecurity/rules.h"
|
||||
@@ -35,15 +36,15 @@ namespace RequestBodyProcessor {
|
||||
|
||||
class JSONContainer {
|
||||
public:
|
||||
JSONContainer(std::string name) : m_name(name) { };
|
||||
virtual ~JSONContainer() { };
|
||||
explicit JSONContainer(std::string name) : m_name(name) { }
|
||||
virtual ~JSONContainer() { }
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
class JSONContainerArray : public JSONContainer {
|
||||
public:
|
||||
JSONContainerArray(std::string name) : JSONContainer(name),
|
||||
explicit JSONContainerArray(std::string name) : JSONContainer(name),
|
||||
m_elementCounter(0) { }
|
||||
size_t m_elementCounter;
|
||||
};
|
||||
@@ -51,7 +52,7 @@ class JSONContainerArray : public JSONContainer {
|
||||
|
||||
class JSONContainerMap : public JSONContainer {
|
||||
public:
|
||||
JSONContainerMap(std::string name) : JSONContainer(name) { }
|
||||
explicit JSONContainerMap(std::string name) : JSONContainer(name) { }
|
||||
};
|
||||
|
||||
|
||||
@@ -89,7 +90,8 @@ class JSON {
|
||||
if (m_containers.size() < 1) {
|
||||
return false;
|
||||
}
|
||||
prev = dynamic_cast<JSONContainerArray *>(m_containers[m_containers.size() - 1]);
|
||||
prev = dynamic_cast<JSONContainerArray *>(
|
||||
m_containers[m_containers.size() - 1]);
|
||||
return prev != NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user