[gmime] Updated gmime-param.c to respect GMimeParserOptions



commit e122f5ea25855b4ace992525c9dd8a6277a1b5cd
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Wed Mar 8 21:28:28 2017 -0500

    Updated gmime-param.c to respect GMimeParserOptions
    
    Also dropped --enable-strict-parser from configure.ac

 configure.ac        |    9 ---------
 gmime/gmime-param.c |   43 +++++++++++++++++++++----------------------
 2 files changed, 21 insertions(+), 31 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index be8272b..a4c0f8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -226,15 +226,6 @@ if test "x$enable_warnings" = "xyes"; then
   AC_DEFINE(ENABLE_WARNINGS, 1, [Define if GMime should enable warning output.])
 fi
 
-dnl Enable stricter MIME parsing rules
-AC_ARG_ENABLE(strict-parser,
-              AC_HELP_STRING([--enable-strict-parser],
-             [enable stricter MIME parser rules [[default=no]]]),,
-             [enable_strict_parser="no"])
-if test "x$enable_strict_parser" = "xyes"; then
-  AC_DEFINE(STRICT_PARSER, 1, [Define if GMime should enable stricter parsing rules.])
-fi
-
 dnl ***********************
 dnl *** Tests for iconv ***
 dnl ***********************
diff --git a/gmime/gmime-param.c b/gmime/gmime-param.c
index f3ef360..d4e809a 100644
--- a/gmime/gmime-param.c
+++ b/gmime/gmime-param.c
@@ -164,7 +164,7 @@ decode_quoted_string (const char **in)
 }
 
 static char *
-decode_token (const char **in)
+decode_token (GMimeParserOptions *options, const char **in)
 {
        const char *inptr = *in;
        const char *start;
@@ -172,20 +172,20 @@ decode_token (const char **in)
        skip_cfws (&inptr);
        
        start = inptr;
-#ifdef STRICT_PARSER
-       while (is_ttoken (*inptr))
-               inptr++;
-#else
-       /* Broken mail clients like to make our lives difficult. Scan
-        * for a ';' instead of trusting that the client followed the
-        * specification. */
-       while (*inptr && *inptr != ';')
-               inptr++;
-       
-       /* Scan backwards over any trailing lwsp */
-       while (inptr > start && is_lwsp (inptr[-1]))
-               inptr--;
-#endif
+       if (options->parameters != GMIME_RFC_COMPLIANCE_LOOSE) {
+               while (is_ttoken (*inptr))
+                       inptr++;
+       } else {
+               /* Broken mail clients like to make our lives difficult. Scan
+                * for a ';' instead of trusting that the client followed the
+                * specification. */
+               while (*inptr && *inptr != ';')
+                       inptr++;
+               
+               /* Scan backwards over any trailing lwsp */
+               while (inptr > start && is_lwsp (inptr[-1]))
+                       inptr--;
+       }
        
        if (inptr > start) {
                *in = inptr;
@@ -196,7 +196,7 @@ decode_token (const char **in)
 }
 
 static char *
-decode_value (const char **in)
+decode_value (GMimeParserOptions *options, const char **in)
 {
        const char *inptr = *in;
        
@@ -206,14 +206,13 @@ decode_value (const char **in)
        if (*inptr == '"') {
                return decode_quoted_string (in);
        } else if (is_ttoken (*inptr)) {
-               return decode_token (in);
+               return decode_token (options, in);
        }
        
-#ifndef STRICT_PARSER
-       return decode_token (in);
-#else
+       if (options->parameters == GMIME_RFC_COMPLIANCE_LOOSE)
+               return decode_token (options, in);
+       
        return NULL;
-#endif
 }
 
 /* This function is basically the same as decode_token()
@@ -295,7 +294,7 @@ decode_param (GMimeParserOptions *options, const char **in, char **paramp, char
        
        if (*inptr == '=') {
                inptr++;
-               value = decode_value (&inptr);
+               value = decode_value (options, &inptr);
                
                if (!is_rfc2184 && value) {
                        if (strstr (value, "=?") != NULL) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]