[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
  types.

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"
  
  --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.
  
  Trey
  --0-1553921899-1158781316=:34441--
 
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'):

56a57,58
> #define _GNU_SOURCE
> 
461c463
< 			if (strstr(linebuf, "text/") || strstr(linebuf, "Text/"))
---
> 			if (strcasestr(linebuf, "text/") )
468c470
< 			else if (  strstr(linebuf, "multipart/"))
---
> 			else if (  strcasestr(linebuf, "multipart/"))
504c506
< 			else if (  strstr(linebuf, "message/"))
---
> 			else if (  strcasestr(linebuf, "message/"))
553c555
< 			     && strstr(linebuf, "boundary="))
---
> 			     && strcasestr(linebuf, "boundary="))
556c558
< 			cp = strstr (linebuf, "boundary=");
---
> 			cp = strcasestr (linebuf, "boundary=");



Reply to: