mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Adds support to urlDecodeUni transformation
This commit is contained in:
@@ -105,7 +105,7 @@ Transformation* Transformation::instantiate(std::string a) {
|
||||
IF_MATCH(trim_left) { return new TrimLeft(a); }
|
||||
IF_MATCH(trim_right) { return new TrimRight(a); }
|
||||
IF_MATCH(url_decode) { return new UrlDecode(a); }
|
||||
IF_MATCH(url_decode_uni) { return new UrlDecodeUni(a); }
|
||||
IF_MATCH(urlDecodeUni) { return new UrlDecodeUni(a); }
|
||||
IF_MATCH(url_encode) { return new UrlEncode(a); }
|
||||
IF_MATCH(utf8_to_unicode) { return new Utf8Unicode(a); }
|
||||
|
||||
|
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "actions/transformations/url_decode_uni.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
@@ -24,26 +26,28 @@
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "actions/transformations/transformation.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace actions {
|
||||
namespace transformations {
|
||||
|
||||
UrlDecodeUni::UrlDecodeUni(std::string action)
|
||||
: Transformation(action) {
|
||||
this->action_kind = 1;
|
||||
}
|
||||
|
||||
std::string UrlDecodeUni::evaluate(std::string value,
|
||||
Assay *assay) {
|
||||
/**
|
||||
* @todo Implement the transformation UrlDecodeUni
|
||||
*/
|
||||
assay->debug(4, "Transformation UrlDecodeUni is not implemented yet.");
|
||||
return value;
|
||||
int changed = 0;
|
||||
char *tmp = strdup(value.c_str());
|
||||
int res = urldecode_uni_nonstrict_inplace_ex(assay, (unsigned char *)tmp,
|
||||
value.size(), &changed);
|
||||
std::string ret("");
|
||||
ret.assign(tmp);
|
||||
free(tmp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
} // namespace transformations
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
|
@@ -30,7 +30,9 @@ namespace transformations {
|
||||
|
||||
class UrlDecodeUni : public Transformation {
|
||||
public:
|
||||
explicit UrlDecodeUni(std::string action);
|
||||
explicit UrlDecodeUni(std::string action)
|
||||
: Transformation(action) { }
|
||||
|
||||
std::string evaluate(std::string exp,
|
||||
Assay *assay) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user