commit-mailutils
[Top][All Lists]
Advanced

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

[SCM] GNU Mailutils branch, master, updated. rel-2_1-74-g1a771a6


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. rel-2_1-74-g1a771a6
Date: Mon, 26 Apr 2010 20:10:56 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=1a771a60bf194a84f8e2df404a768ea71623fbf9

The branch, master has been updated
       via  1a771a60bf194a84f8e2df404a768ea71623fbf9 (commit)
      from  5157bbc99fc7cd3c0ea904f70ab2ee1f595ac8fe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1a771a60bf194a84f8e2df404a768ea71623fbf9
Author: Sergey Poznyakoff <address@hidden>
Date:   Mon Apr 26 22:48:29 2010 +0300

    Accept additional whitespace and quotes in the disposition part of MIME 
headers.
    
    * mailbox/mimehdr.c (disp_segment_len): New function.
    (mu_mimehdr_get_disp, mu_mimehdr_aget_disp): Use disp_segment_len.
    Unquote the returned string.
    (_header_get_param): Allow for whitespace before '"'. Unquote the
    string before comparison.

-----------------------------------------------------------------------

Summary of changes:
 mailbox/mimehdr.c |   57 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/mailbox/mimehdr.c b/mailbox/mimehdr.c
index 4c27358..3391868 100644
--- a/mailbox/mimehdr.c
+++ b/mailbox/mimehdr.c
@@ -100,6 +100,7 @@ _header_get_param (const char *field_body,
   int res = MU_ERR_NOENT;            /* Return value, pessimistic default */
   size_t param_len = strlen (param);
   char *p;
+  size_t size;
   char *mem = NULL;                  /* Allocated memory storage */
   size_t retlen = 0;                 /* Total number of bytes copied */
   unsigned long cind = 0;            /* Expected continued parameter index.
@@ -116,7 +117,18 @@ _header_get_param (const char *field_body,
   p = strchr (field_body, ';');
   if (!p)
     return MU_ERR_NOENT;
-  if (disp && mu_c_strncasecmp (field_body, disp, p - field_body))
+  /* Allow for possible whitespace before the semicolon */
+  for (size = p - field_body;
+       size > 0 && mu_isblank (field_body[size-1]); size--)
+    ;
+  /* Remove surrounding quotes.
+     FIXME: unescape the quoted contents. */
+  if (field_body[0] == '"' && field_body[size-1] == '"')
+    {
+      field_body++;
+      size -= 2;
+    }
+  if (disp && mu_c_strncasecmp (field_body, disp, size))
     return MU_ERR_NOENT;
       
   while (p && *p)
@@ -326,6 +338,21 @@ _header_get_param (const char *field_body,
   return res;
 }
 
+static size_t
+disp_segment_len (const char *str)
+{
+  char *p = strchr (str, ';');
+  size_t size;
+  
+  if (!p)
+    size = strlen (str);
+  else
+    size = p - str;
+  while (size > 0 && mu_isblank (str[size-1]))
+    size--;
+  return size;
+}
+
 /* STR is a value of a structured MIME header, e.g. Content-Type.
    This function returns the `disposition part' of it.  In other
    words, it returns disposition, if STR is a Content-Disposition
@@ -334,13 +361,15 @@ _header_get_param (const char *field_body,
 int
 mu_mimehdr_get_disp (const char *str, char *buf, size_t bufsz, size_t *retsz)
 {
-  char *p = strchr (str, ';');
   size_t size;
-  
-  if (!p)
-    size = strlen (str);
-  else
-    size = p - str;
+
+  str = mu_str_skip_class (str, MU_CTYPE_BLANK);
+  size = disp_segment_len (str);
+  if (size > 2 && str[0] == '"' && str[size-1] == '"')
+    {
+      str++;
+      size -= 2;
+    }
   if (buf)
     size = mu_cpystr (buf, str, size);
   if (retsz)
@@ -352,13 +381,17 @@ mu_mimehdr_get_disp (const char *str, char *buf, size_t 
bufsz, size_t *retsz)
 int
 mu_mimehdr_aget_disp (const char *str, char **pvalue)
 {
-  char *p = strchr (str, ';');
+  char *p;
   size_t size;
   
-  if (!p)
-    size = strlen (str);
-  else
-    size = p - str;
+  str = mu_str_skip_class (str, MU_CTYPE_BLANK);
+  size = disp_segment_len (str);
+  if (size > 2 && str[0] == '"' && str[size-1] == '"')
+    {
+      str++;
+      size -= 2;
+    }
+
   p = malloc (size + 1);
   if (!p)
     return ENOMEM;


hooks/post-receive
-- 
GNU Mailutils




reply via email to

[Prev in Thread] Current Thread [Next in Thread]