Menu

Stripping double quotes from header values

2010-09-28
2013-04-22
  • Hristo Deshev

    Hristo Deshev - 2010-09-28

    Hi guys,

    I'm using SharpMimeTools and I am really happy with it. Really great job!

    I noticed a small problem though - subjects got double quotes stripped from them. I believe all headers have it this way after looking at the SharpMimeTools.parserfc2047Header method:

    public static System.String parserfc2047Header ( System.String header ) {
    header = header.Replace ("\"", System.String.Empty);
    header = anmar.SharpMimeTools.SharpMimeTools.rfc2047decode(header);
    return header;
    }

    That Replace call doesn't feel right. I think double quotes are a valid character in headers. To me it looks like a fix for some edge case. Anyone know more about it?

    Best,
    Hristo

     
  • Hristo Deshev

    Hristo Deshev - 2010-09-29

    I just went ahead and did the change - removed the Replace() call above. The only thing I noticed is that sometimes parsed addresses will contain quotes in their display names (message.From for example). I dealt with that in my app by stripping quotes only for address display names. I know I should be probably doing something smarter like looking for escaped \" quotes, but stripping quotes suits my needs for now.

    Best,
    Hristo

     

Log in to post a comment.