Skip to content

Commit

Permalink
[Minor] Strip some bad characters from CTE headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Apr 8, 2019
1 parent e8f8cc3 commit fe8028c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/libmime/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ rspamd_message_process_plain_text_part (struct rspamd_task *task,
/* Check for ical */
rspamd_ftok_t cal_ct;

/*
* TODO: If we want to process more than that, we need
* to create some generic framework that accepts a part
* and returns a processed data
*/
RSPAMD_FTOK_ASSIGN (&cal_ct, "calendar");

if (rspamd_ftok_casecmp (&cal_ct, &text_part->mime_part->ct->subtype) == 0) {
Expand Down
7 changes: 5 additions & 2 deletions src/libmime/mime_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,13 @@ rspamd_mime_parser_init_lib (void)
static enum rspamd_cte
rspamd_mime_parse_cte (const gchar *in, gsize len)
{
guint64 h = rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64,
in, len, 0xdeadbabe);
guint64 h;
enum rspamd_cte ret = RSPAMD_CTE_UNKNOWN;

in = rspamd_string_len_strip (in, &len, " \t;,.+-#!`~'");
h = rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64,
in, len, 0xdeadbabe);

switch (h) {
case 0xCEDAA7056B4753F7ULL: /* 7bit */
ret = RSPAMD_CTE_7BIT;
Expand Down

0 comments on commit fe8028c

Please sign in to comment.