aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_encoding.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-25 13:21:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-25 13:21:51 +0100
commita03b2c328b0c9cb332527adb584b6e3496de5e46 (patch)
treea46ff1eabb22c94e76324805be0d38d6ae8efa72 /src/libmime/mime_encoding.c
parentd21fdd376f883510ae2bf5de7307eb59d84cb614 (diff)
downloadrspamd-a03b2c328b0c9cb332527adb584b6e3496de5e46.tar.gz
rspamd-a03b2c328b0c9cb332527adb584b6e3496de5e46.zip
[Fix] Deal with 8bit characters in email addresses
Diffstat (limited to 'src/libmime/mime_encoding.c')
-rw-r--r--src/libmime/mime_encoding.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c
index 11f764e11..97eede726 100644
--- a/src/libmime/mime_encoding.c
+++ b/src/libmime/mime_encoding.c
@@ -455,36 +455,6 @@ rspamd_mime_charset_utf_check (rspamd_ftok_t *charset,
return FALSE;
}
-/* https://graphics.stanford.edu/~seander/bithacks.html#HasMoreInWord */
-#define hasmore(x,n) (((x)+~0UL/255*(127-(n))|(x))&~0UL/255*128)
-
-static inline gboolean
-rspamd_mime_has_8bit (const guchar *beg, gsize len)
-{
- unsigned long *w;
- gsize i, leftover = len % sizeof (*w);
-
- w = (unsigned long *)beg;
-
- for (i = 0; i < len / sizeof (*w); i ++) {
- if (hasmore (*w, 127)) {
- return TRUE;
- }
-
- w ++;
- }
-
- beg = (const guchar *)w;
-
- for (i = 0; i < leftover; i ++) {
- if (beg[i] > 127) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
GByteArray *
rspamd_mime_text_part_maybe_convert (struct rspamd_task *task,
struct rspamd_mime_text_part *text_part)
@@ -498,7 +468,7 @@ rspamd_mime_text_part_maybe_convert (struct rspamd_task *task,
rspamd_ftok_t charset_tok;
struct rspamd_mime_part *part = text_part->mime_part;
- if (rspamd_mime_has_8bit (text_part->raw.begin, text_part->raw.len)) {
+ if (rspamd_str_has_8bit (text_part->raw.begin, text_part->raw.len)) {
text_part->flags |= RSPAMD_MIME_TEXT_PART_FLAG_8BIT;
}
@@ -508,7 +478,7 @@ rspamd_mime_text_part_maybe_convert (struct rspamd_task *task,
memcpy (part_content->data, text_part->parsed.begin, text_part->parsed.len);
part_content->len = text_part->parsed.len;
- if (rspamd_mime_has_8bit (text_part->parsed.begin, text_part->parsed.len)) {
+ if (rspamd_str_has_8bit (text_part->parsed.begin, text_part->parsed.len)) {
text_part->flags |= RSPAMD_MIME_TEXT_PART_FLAG_8BIT_ENCODED;
}