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 #ifndef SRC_OPERATORS_VALIDATE_UTF8_ENCODING_H_ 17 #define SRC_OPERATORS_VALIDATE_UTF8_ENCODING_H_ 18 19 #include <string> 20 #include <memory> 21 22 #include "src/operators/operator.h" 23 24 25 #define UNICODE_ERROR_CHARACTERS_MISSING -1 26 #define UNICODE_ERROR_INVALID_ENCODING -2 27 #define UNICODE_ERROR_OVERLONG_CHARACTER -3 28 #define UNICODE_ERROR_RESTRICTED_CHARACTER -4 29 #define UNICODE_ERROR_DECODING_ERROR -5 30 31 32 namespace modsecurity { 33 namespace operators { 34 35 class ValidateUtf8Encoding : public Operator { 36 public: 37 /** @ingroup ModSecurity_Operator */ ValidateUtf8Encoding()38 ValidateUtf8Encoding() 39 : Operator("ValidateUtf8Encoding") { } 40 41 bool evaluate(Transaction *transaction, RuleWithActions *rule, 42 const std::string &str, 43 std::shared_ptr<RuleMessage> ruleMessage) override; 44 45 static int detect_utf8_character(const unsigned char *p_read, 46 unsigned int length); 47 }; 48 49 } // namespace operators 50 } // namespace modsecurity 51 52 53 54 #endif // SRC_OPERATORS_VALIDATE_UTF8_ENCODING_H_ 55