Skip to content

Commit

Permalink
util: remove unused htp_utf8_decode
Browse files Browse the repository at this point in the history
Only used in a specific test
  • Loading branch information
catenacyber authored and victorjulien committed Jan 26, 2022
1 parent 893a858 commit 966c400
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
20 changes: 0 additions & 20 deletions htp/htp_utf8_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,6 @@ static const uint8_t utf8d_allow_overlong[] = {
1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8
};

/**
* Process one byte of UTF-8 data and return a code point if one is available.
*
* @param[in] state
* @param[in] codep
* @param[in] byte
* @return HTP_UTF8_ACCEPT for a valid character, HTP_UTF8_REJECT for an invalid character,
* or something else if the character has not yet been formed
*/
uint32_t htp_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
uint32_t type = utf8d[byte];

*codep = (*state != HTP_UTF8_ACCEPT) ?
(byte & 0x3fu) | (*codep << 6) :
(0xff >> type) & (byte);

*state = utf8d[256 + *state*16 + type];
return *state;
}

/**
* Process one byte of UTF-8 data and return a code point if one is available. Allows
* overlong characters in input.
Expand Down
1 change: 0 additions & 1 deletion htp/htp_utf8_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ extern "C" {
#define HTP_UTF8_ACCEPT 0
#define HTP_UTF8_REJECT 1

uint32_t htp_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte);
uint32_t htp_utf8_decode_allow_overlong(uint32_t* state, uint32_t* codep, uint32_t byte);

#ifdef __cplusplus
Expand Down
11 changes: 0 additions & 11 deletions test/test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@
#include <gtest/gtest.h>
#include <htp/htp_private.h>

TEST(Utf8, SingleByte) {
uint32_t state = HTP_UTF8_ACCEPT;
uint32_t codep;
uint32_t result;

result = htp_utf8_decode(&state, &codep, 0x00);
EXPECT_EQ(0, result);
EXPECT_EQ(HTP_UTF8_ACCEPT, state);
EXPECT_EQ(0, codep);
}

TEST(Base64, Single) {
EXPECT_EQ(62, htp_base64_decode_single('+'));
EXPECT_EQ(63, htp_base64_decode_single('/'));
Expand Down

0 comments on commit 966c400

Please sign in to comment.