1 /*
2  * ModSecurity, http://www.modsecurity.org/
3  * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/)
4  *
5  * You may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * If any of the files related to licensing are missing or if you have any
11  * other questions related to licensing please contact Trustwave Holdings, Inc.
12  * directly using the email address security@modsecurity.org.
13  *
14  */
15 
16 #include <string>
17 
18 #include "modsecurity/actions/action.h"
19 #include "src/actions/transformations/transformation.h"
20 
21 #ifndef SRC_ACTIONS_TRANSFORMATIONS_UTF8_TO_UNICODE_H_
22 #define SRC_ACTIONS_TRANSFORMATIONS_UTF8_TO_UNICODE_H_
23 
24 #define UNICODE_ERROR_CHARACTERS_MISSING    -1
25 #define UNICODE_ERROR_INVALID_ENCODING      -2
26 #define UNICODE_ERROR_OVERLONG_CHARACTER    -3
27 #define UNICODE_ERROR_RESTRICTED_CHARACTER  -4
28 #define UNICODE_ERROR_DECODING_ERROR        -5
29 
30 namespace modsecurity {
31 class Transaction;
32 
33 namespace actions {
34 namespace transformations {
35 
36 class Utf8ToUnicode : public Transformation {
37  public:
Utf8ToUnicode(const std::string & action)38     explicit Utf8ToUnicode(const std::string &action)  : Transformation(action) { }
39 
40     std::string evaluate(const std::string &exp,
41         Transaction *transaction) override;
42 
43     static char *inplace(unsigned char *input, uint64_t input_len,
44         int *changed);
45 };
46 
47 }  // namespace transformations
48 }  // namespace actions
49 }  // namespace modsecurity
50 
51 
52 #endif  // SRC_ACTIONS_TRANSFORMATIONS_UTF8_TO_UNICODE_H_
53