mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 19:47:47 +03:00
Replaced VALID_HEX, ISODIGIT & NBSP macros in string.h
- Moved them into modsecurity::utils::string to avoid polluting the global namespace.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "src/utils/string.h"
|
#include "src/utils/string.h"
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "src/utils/string.h"
|
#include "src/utils/string.h"
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "src/compat/msvc.h"
|
#include "src/compat/msvc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "src/utils/string.h"
|
#include "src/utils/string.h"
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "src/utils/string.h"
|
#include "src/utils/string.h"
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include "modsecurity/rules_set.h"
|
#include "modsecurity/rules_set.h"
|
||||||
#include "src/utils/string.h"
|
#include "src/utils/string.h"
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity::actions::transformations {
|
namespace modsecurity::actions::transformations {
|
||||||
|
|
||||||
|
@@ -17,9 +17,9 @@
|
|||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
#include "src/utils/string.h"
|
#include "src/utils/string.h"
|
||||||
|
|
||||||
|
using namespace modsecurity::utils::string;
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity::utils {
|
||||||
namespace utils {
|
|
||||||
|
|
||||||
|
|
||||||
bool urldecode_nonstrict_inplace(std::string &val,
|
bool urldecode_nonstrict_inplace(std::string &val,
|
||||||
@@ -112,5 +112,4 @@ std::string uri_decode(const std::string & sSrc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace modsecurity::utils
|
||||||
} // namespace modsecurity
|
|
||||||
|
@@ -13,6 +13,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_UTILS_STRING_H_
|
||||||
|
#define SRC_UTILS_STRING_H_
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -27,18 +30,21 @@
|
|||||||
#include "src/compat/msvc.h"
|
#include "src/compat/msvc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SRC_UTILS_STRING_H_
|
namespace modsecurity::utils::string {
|
||||||
#define SRC_UTILS_STRING_H_
|
|
||||||
|
|
||||||
#define VALID_HEX(X) (((X >= '0') && (X <= '9')) || \
|
template<typename CharT>
|
||||||
((X >= 'a') && (X <= 'f')) || ((X >= 'A') && (X <= 'F')))
|
constexpr bool VALID_HEX(CharT X) {
|
||||||
#define ISODIGIT(X) ((X >= '0') && (X <= '7'))
|
return ((X >= '0') && (X <= '9'))
|
||||||
#define NBSP 160
|
|| ((X >= 'a') && (X <= 'f'))
|
||||||
|
|| ((X >= 'A') && (X <= 'F'));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename CharT>
|
||||||
|
constexpr bool ISODIGIT(CharT X) {
|
||||||
|
return (X >= '0') && (X <= '7');
|
||||||
|
}
|
||||||
|
|
||||||
namespace modsecurity {
|
constexpr unsigned char NBSP = 160;
|
||||||
namespace utils {
|
|
||||||
namespace string {
|
|
||||||
|
|
||||||
const char HEX2DEC[256] = {
|
const char HEX2DEC[256] = {
|
||||||
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
|
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
|
||||||
@@ -271,8 +277,6 @@ inline std::string toupper(std::string str) { // cppcheck-suppress passedByValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace string
|
} // namespace modsecurity::utils::string
|
||||||
} // namespace utils
|
|
||||||
} // namespace modsecurity
|
|
||||||
|
|
||||||
#endif // SRC_UTILS_STRING_H_
|
#endif // SRC_UTILS_STRING_H_
|
||||||
|
Reference in New Issue
Block a user