Attempt to fix that and some more:

mimedecode (1.9-4cii0) unstable; urgency=low

  * Make the outside and inside versions agree.
  * Tweak the man page to get a name description. Closes: #515016.
  * Stolen fixes from upstream (Darren Salt), who's at version 1.10 since 2003
    and suggested an upgrade in Dec 2002, see #173631 and
    http://www.youmustbejoking.demon.co.uk/progs.linux.html#mimedecode.
  * More case tolerant on headers stuff. Closes: #399677.
  * Fixes assertion in decode_header_line. Closes: #385011. Closes: #385325.
  * Comment on #294523: mimedecode acts on headers. Using formail to extract
    the Subject will remove the 'header' part. Use grep instead of formail and
    it will work.

 -- Cristian Ionescu-Idbohrn <c...@axis.com>  Sun, 24 May 2009 12:06:31 +0200

--- mimedecode.c.original       2009-05-22 12:12:51.000000000 +0200
+++ mimedecode.c        2009-05-24 10:40:59.000000000 +0200
@@ -64,7 +64,7 @@

 /* Some defines. Should have gone into a file by itself.
  */
-#define MIMED_VERSION "mimedecode version 1.8"
+#define MIMED_VERSION "mimedecode version 1.9"

 #define FALSE 0
 #define TRUE  1
@@ -124,6 +124,7 @@
 static int parse_body(int, int, char *);
 static int parse_header(struct mime_header *);
 static char *decode_header_line(char *);
+static int is_mimetype(const char *, const char *);
 static void print_state(int);
 static int casncmp(const char *, const char *, int);
 static int valid_charset(char *, int);
@@ -455,17 +456,20 @@

                    if (!casncmp(linebuf,"content-type:",13))
                    {
+                       const char *content = linebuf + 12;
+                       while (isspace(*(++content)))
+                           ;
                        ct_read = TRUE;

                        /* we are only doing decoding of text types */
-                       if (strstr(linebuf, "text/") || strstr(linebuf, 
"Text/"))
+                       if (is_mimetype(content, "text/"))
                        {
                            if (debug >=3 )
                                fprintf(stderr,"Content IS text\n");

                            mhp->content_type = TEXT;
                        }
-                       else if (  strstr(linebuf, "multipart/"))
+                       else if (is_mimetype(content, "multipart/"))
                        {
                            mhp->content_type = MULT;

@@ -501,7 +505,7 @@
                                }
                            }
                        }
-                       else if (  strstr(linebuf, "message/"))
+                       else if (is_mimetype(content, "message/"))
                        {
                            mhp->content_type = MESG;
                        }
@@ -933,8 +937,12 @@
        }
        *retp++ = c;
     }
-    if (state != HUNT) {

+    if (header_logging) print_state (state);
+
+    if (state != HUNT
+       && state != B_FIELD && state != Q_FIELD
+       && state != DEC1 && state != DEC2) {
        *retp++ = '=';
        *retp++ = '?';
        while (*charset) *retp++ = *charset++;
@@ -947,6 +955,22 @@


 /*******************************************************************/
+static int is_mimetype(content, type)
+/*******************************************************************/
+const char *content, *type;
+{
+    int l = strlen(type);        /* assumed non-zero */
+
+    if (type[l - 1] == '/')
+       return !casncmp(content, type, l);
+
+    return !casncmp(content, type, l) &&
+       (content[l] == '\0' || content[l] == ';' || isspace(content[l]));
+}
+
+
+
+/*******************************************************************/
 static void print_state(state)
 /*******************************************************************/
 int    state;


Cheers,

-- 
Cristian



-- 
To UNSUBSCRIBE, email to debian-qa-packages-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to