[gmime: 10/27] Use g_utf8_validate instead of is_7bit_clean because of newer international mail standards
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime: 10/27] Use g_utf8_validate instead of is_7bit_clean because of newer international mail standards
- Date: Thu, 23 Nov 2017 15:44:45 +0000 (UTC)
commit 398b3d97a5f1af8a644ec3f922ca7fa53795a2a3
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date: Wed Nov 8 16:17:21 2017 -0500
Use g_utf8_validate instead of is_7bit_clean because of newer international mail standards
gmime/gmime-parser.c | 29 ++++++++---------------------
1 files changed, 8 insertions(+), 21 deletions(-)
---
diff --git a/gmime/gmime-parser.c b/gmime/gmime-parser.c
index eaa61c7..1b6d47a 100644
--- a/gmime/gmime-parser.c
+++ b/gmime/gmime-parser.c
@@ -263,8 +263,8 @@ parser_find_header (GMimeParser *parser, const char *name, gint64 *offset)
Header *header;
guint i;
- for (i = priv->headers->len; i > 0U; --i) {
- header = priv->headers->pdata[i - 1U];
+ for (i = priv->headers->len; i > 0; i--) {
+ header = priv->headers->pdata[i - 1];
if (g_ascii_strcasecmp (header->name, name) != 0)
continue;
@@ -869,17 +869,6 @@ 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)
{
@@ -908,12 +897,10 @@ header_parse (GMimeParser *parser, GMimeParserOptions *options)
if (*inptr != ':') {
/* ignore invalid headers */
- if (strcmp(priv->headerbuf, "\r") != 0) {
- _g_mime_parser_options_warn (options, priv->header_offset, GMIME_WARN_INVALID_HEADER,
priv->headerbuf);
- w(g_warning ("Invalid header at %lld: '%s'",
- (long long) priv->header_offset,
- priv->headerbuf));
- }
+ _g_mime_parser_options_warn (options, priv->header_offset, GMIME_WARN_INVALID_HEADER,
priv->headerbuf);
+ w(g_warning ("Invalid header at %lld: '%s'",
+ (long long) priv->header_offset,
+ priv->headerbuf));
if (priv->preheader == NULL)
priv->preheader = g_strdup (priv->headerbuf);
@@ -942,9 +929,9 @@ header_parse (GMimeParser *parser, GMimeParserOptions *options)
if (priv->regex && g_regex_match (priv->regex, header->name, 0, NULL))
priv->header_cb (parser, header->name, header->raw_value,
header->offset, priv->user_data);
- if (!is_7bit_clean (header->raw_name) || !is_7bit_clean (header->raw_value)) {
+
+ if (!g_utf8_validate (header->raw_value, -1, NULL))
_g_mime_parser_options_warn (options, header->offset, GMIME_WARN_UNENCODED_8BIT_HEADER,
header->name);
- }
}
enum {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]