Attachments with ) in filename

Dec 10, 2009 at 10:17 PM

Hi Guys,

the attachments regex in ImapMessageBodyPart.cs doesn't work when there is a ) in an attachment name.

I've changed it to

 const string attachment = "^\\((?<type>(\"[^\"]*\"|NIL))\\s(?<subtype>(\"[^\"]*\"|NIL))\\s(?<attr>(\\((\"[^\"]*\"(\\s)?)*\\)|NIL))\\s(?<id>(\"[^\"]*\"|NIL))\\s(?<desc>(\"[^\"]*\"|NIL))\\s(?<encoding>(\"[^\"]*\"|NIL))\\s(?<size>(\\d+|NIL))\\s((?<data>(.*))\\s|)(?<lines>(\"[^\"]*\"|NIL))\\s(?<disposition>((?>\\((?<LEVEL>)|\\)(?<-LEVEL>)|(?!\\(|\\)).)+(?(LEVEL)(?!))|NIL))\\s(?<lang>(\"[^\"]*\"|NIL))\\)$";

which seemed to fix the issue...

Change was the <attr> section

from

(?<attr>(\\([^\\)]*\\)|NIL))

to

(?<attr>(\\((\"[^\"]*\"(\\s)?)*\\)|NIL))

which allows for multiple tokens enclosed in quotation marks. eg

("x-mac-creator" "5E435F73" "x-mac-type" "403B4755" "name" "dxX(copy).png")

 

 

Mar 4, 2011 at 7:15 PM

It works! Thanks.