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

Bug#399677: patch for incorrect mimedecode case-sensitivity

Package: mimedecode
Version: 1.9-4

mimedecode does not comply with RFC 2045 (MIME), which says:
  The type, subtype, and parameter names are not case sensitive.  For
  example, TEXT, Text, and TeXt are all equivalent top-level media

It's simple to fix: 
  change all 'strstr' to 'strcasestr'
  insert '#define _GNU_SOURCE' before including string.h

See below for an example & a patch.

Brian Keck


An example of a message that's handled incorrectly:

  Date: Wed, 20 Sep 2006 12:42:57 -0700 (PDT)
  From: Trey Harris <trey@lopsa.org>
  To: Larry Wall <larry@wall.org>
  Subject: Re: Capture sigil
  Message-ID: <20060920123318.R34441@bowser.eecs.harvard.edu>
  MIME-Version: 1.0
  Content-Type: MULTIPART/MIXED; BOUNDARY="0-1553921899-1158781316=:34441"
  Content-Type: TEXT/PLAIN; CHARSET=UTF-8; FORMAT=flowed
  Content-Transfer-Encoding: QUOTED-PRINTABLE
  Content-ID: <20060920124244.D34441@bowser.eecs.harvard.edu>
  In a message dated Wed, 20 Sep 2006, Larry Wall writes:
  > The obvious ASCII for =C2=A2 would be c/ or C/ or c| or c| or maybe just =
  I like =C2=A2,but:
      c/$foo # ASCII of =C2=A2$foo
      d/$foo # d() divided by $foo
  is rather confusing.  (Same goes for |).
  So the Term Term exclusion makes me rather lean towards |.  Whether it's
  the canonical sigil or the ASCII of =C2=A2 doesn't much matter to me.
This passes through the current mimedecode unchanged.
It's correctly decoded with the above changes.


A patch to make the changes described above (this applies to
mimedecode.c as produced by 'apt-get source mimedecode'):

> #define _GNU_SOURCE
< 			if (strstr(linebuf, "text/") || strstr(linebuf, "Text/"))
> 			if (strcasestr(linebuf, "text/") )
< 			else if (  strstr(linebuf, "multipart/"))
> 			else if (  strcasestr(linebuf, "multipart/"))
< 			else if (  strstr(linebuf, "message/"))
> 			else if (  strcasestr(linebuf, "message/"))
< 			     && strstr(linebuf, "boundary="))
> 			     && strcasestr(linebuf, "boundary="))
< 			cp = strstr (linebuf, "boundary=");
> 			cp = strcasestr (linebuf, "boundary=");

Reply to: