aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-09-10 17:45:30 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-09-10 17:45:30 +0100
commitc21b3a8e3db223eb215ef17d0ea1762de694ea73 (patch)
tree3e35f0f1e52e31f6e3f2bed221ccd7a35cf398c1 /src
parent0ef1054d00fdc1c13aa5e202c2f276b9207c51a0 (diff)
downloadrspamd-c21b3a8e3db223eb215ef17d0ea1762de694ea73.tar.gz
rspamd-c21b3a8e3db223eb215ef17d0ea1762de694ea73.zip
Fix bug with charset conversion.
Glib iconv understands only uppercase for charset names.
Diffstat (limited to 'src')
-rw-r--r--src/libmime/message.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index fff55b4fe..f4ab2211f 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -824,7 +824,7 @@ charset_validate (rspamd_mempool_t *pool, const gchar *in, gchar **out)
* with alphanumeric
*/
const gchar *begin, *end;
- gboolean changed = FALSE;
+ gboolean changed = FALSE, to_uppercase = FALSE;
begin = in;
@@ -832,6 +832,10 @@ charset_validate (rspamd_mempool_t *pool, const gchar *in, gchar **out)
begin ++;
changed = TRUE;
}
+ if (!g_ascii_islower(*begin)) {
+ changed = TRUE;
+ to_uppercase = TRUE;
+ }
end = begin + strlen (begin) - 1;
while (!g_ascii_isalnum (*end)) {
end --;
@@ -843,7 +847,22 @@ charset_validate (rspamd_mempool_t *pool, const gchar *in, gchar **out)
}
else {
*out = rspamd_mempool_alloc (pool, end - begin + 2);
- rspamd_strlcpy (*out, begin, end - begin + 2);
+ if (to_uppercase) {
+ gchar *o = *out;
+
+ while (begin != end + 1) {
+ if (g_ascii_islower (*begin)) {
+ *o++ = g_ascii_toupper (*begin ++);
+ }
+ else {
+ *o++ = *begin++;
+ }
+ }
+ *o = '\0';
+ }
+ else {
+ rspamd_strlcpy (*out, begin, end - begin + 2);
+ }
}
return TRUE;
@@ -908,6 +927,7 @@ convert_text_to_utf (struct rspamd_task *task,
ocharset,
err ? err->message : "unknown problem");
text_part->is_raw = TRUE;
+ g_error_free (err);
return part_content;
}