[gmime: 17/27] restore detection of wrongly coded header field names (#30)
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 17/27] restore detection of wrongly coded header field names (#30)
- Date: Thu, 23 Nov 2017 15:45:20 +0000 (UTC)
commit 39a400855f0febffda01c9a20bdd38e7b0eb1ba9
Author: albrechtd <albrecht dress arcor de>
Date: Thu Nov 9 21:36:00 2017 +0100
restore detection of wrongly coded header field names (#30)
restore detection of wrongly coded header field names
gmime/gmime-parser.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gmime/gmime-parser.c b/gmime/gmime-parser.c
index c641e3f..e4523f0 100644
--- a/gmime/gmime-parser.c
+++ b/gmime/gmime-parser.c
@@ -869,6 +869,17 @@ next_alloc_size (size_t n)
priv->headerleft -= len; \
} G_STMT_END
+static inline gboolean
+is_7bit_clean (const gchar *str)
+{
+ for (; *str != '\0'; str++) {
+ if ((*str & 0x80) != 0) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
static void
header_parse (GMimeParser *parser, GMimeParserOptions *options)
{
@@ -931,7 +942,7 @@ header_parse (GMimeParser *parser, GMimeParserOptions *options)
priv->header_cb (parser, header->name, header->raw_value,
header->offset, priv->user_data);
- if (can_warn && !g_utf8_validate (header->raw_value, -1, NULL))
+ if (can_warn && (!is_7bit_clean(header->name) || !g_utf8_validate (header->raw_value, -1, NULL)))
_g_mime_parser_options_warn (options, header->offset, GMIME_WARN_UNENCODED_8BIT_HEADER,
header->name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]