mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +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);
|
||||
|
||||
if (tolower(key) == tolower("Authorization")) {
|
||||
std::string keyl = tolower(key);
|
||||
if (keyl == "authorization") {
|
||||
std::vector<std::string> type = split(value, ' ');
|
||||
this->m_collections.store("AUTH_TYPE", type[0]);
|
||||
}
|
||||
|
||||
if (tolower(key) == "cookie") {
|
||||
if (keyl == "cookie") {
|
||||
std::vector<std::string> cookies = split(value, ';');
|
||||
while (cookies.empty() == false) {
|
||||
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 l = tolower(value);
|
||||
|
||||
|
10
src/utils.cc
10
src/utils.cc
@ -25,7 +25,7 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
@ -126,10 +126,12 @@ void chomp(std::string *str) {
|
||||
std::string tolower(std::string str) {
|
||||
std::locale loc;
|
||||
std::string value;
|
||||
value.resize(str.length());
|
||||
|
||||
for (std::string::size_type i=0; i < str.length(); ++i) {
|
||||
value.assign(value + std::tolower(str[i], loc));
|
||||
}
|
||||
std::transform(str.begin(),
|
||||
str.end(),
|
||||
value.begin(),
|
||||
::tolower);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user