mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Optimization on the tolower function
This commit is contained in:
parent
0762892368
commit
8c7b6199f7
@ -433,12 +433,13 @@ int Assay::addRequestHeader(const std::string& key,
|
|||||||
|
|
||||||
this->m_collections.store("REQUEST_HEADERS:" + key, value);
|
this->m_collections.store("REQUEST_HEADERS:" + key, value);
|
||||||
|
|
||||||
if (tolower(key) == tolower("Authorization")) {
|
std::string keyl = tolower(key);
|
||||||
|
if (keyl == "authorization") {
|
||||||
std::vector<std::string> type = split(value, ' ');
|
std::vector<std::string> type = split(value, ' ');
|
||||||
this->m_collections.store("AUTH_TYPE", type[0]);
|
this->m_collections.store("AUTH_TYPE", type[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tolower(key) == "cookie") {
|
if (keyl == "cookie") {
|
||||||
std::vector<std::string> cookies = split(value, ';');
|
std::vector<std::string> cookies = split(value, ';');
|
||||||
while (cookies.empty() == false) {
|
while (cookies.empty() == false) {
|
||||||
std::vector<std::string> s = split(cookies.back(), '=');
|
std::vector<std::string> s = split(cookies.back(), '=');
|
||||||
@ -461,7 +462,7 @@ int Assay::addRequestHeader(const std::string& key,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (tolower(key) == "content-type") {
|
if (keyl == "content-type") {
|
||||||
std::string multipart("multipart/form-data");
|
std::string multipart("multipart/form-data");
|
||||||
std::string l = tolower(value);
|
std::string l = tolower(value);
|
||||||
|
|
||||||
|
10
src/utils.cc
10
src/utils.cc
@ -25,7 +25,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -126,10 +126,12 @@ void chomp(std::string *str) {
|
|||||||
std::string tolower(std::string str) {
|
std::string tolower(std::string str) {
|
||||||
std::locale loc;
|
std::locale loc;
|
||||||
std::string value;
|
std::string value;
|
||||||
|
value.resize(str.length());
|
||||||
|
|
||||||
for (std::string::size_type i=0; i < str.length(); ++i) {
|
std::transform(str.begin(),
|
||||||
value.assign(value + std::tolower(str[i], loc));
|
str.end(),
|
||||||
}
|
value.begin(),
|
||||||
|
::tolower);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user