1

Closed

Decode header line tough case

description

First of all, thanks! It is cool lib. It realy helps me in one of my current project.
I found bottleneck in MailParser.DecodeFromMailHeaderLine method.
In my case I received following header in letter:
=?ISO-8859-1?Q?Tunisian_'Unity'_Government_in_Jeopardy=20?=
 
So, according current algo in DecodeFromMailHeaderLine, it was parsed by RFC 2231 (RegexList.DecodeByRfc2231)
But we should use RFC 2047 for this line pattern.
 
So, my proposal is to fix this case in something like this:
 
public static String DecodeFromMailHeaderLine(String line)
    {
    Regex rg = RegexList.DecodeByRfc2047;
        MatchCollection mc = null;
        Match m = null;
        ...
 
        m = RegexList.DecodeByRfc2231.Match(line);
        mc = rg.Matches(line);
        if (m.Success && mc.Count == 0)
        {
           ...
        }
        else
        {
            //mc = rg.Matches(line);
            for (int i = 0; i < mc.Count; i++)
            {
                m = mc[i];
...
}
 
Thanks:)
Closed Sep 20, 2011 at 2:22 PM by higty

comments

higty wrote Feb 16, 2011 at 5:44 AM

I fixed this bug as your proposal.
Check new version.
Thank you!!

wrote Sep 20, 2011 at 2:22 PM

wrote Feb 14, 2013 at 6:38 PM

wrote May 16, 2013 at 8:35 AM