diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-07-15 23:03:14 -0700 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-07-15 23:03:34 -0700 |
commit | dd6e71efeb4cc0260df4646fb222de217528790b (patch) | |
tree | f33e621d30fdc4a0399a85ba6a0b4245d2f626f6 | |
parent | 1c4906300f67bfd2f6d8f248659228863983bbc5 (diff) |
Fixed #689: fixed parser in case it's starting with mbox delimiter
-rw-r--r-- | src/core/rfc822/MCMessageBuilder.cc | 6 | ||||
-rw-r--r-- | src/core/rfc822/MCMessageParser.cc | 19 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/core/rfc822/MCMessageBuilder.cc b/src/core/rfc822/MCMessageBuilder.cc index 384bb4e5..cd87009e 100644 --- a/src/core/rfc822/MCMessageBuilder.cc +++ b/src/core/rfc822/MCMessageBuilder.cc @@ -580,6 +580,9 @@ Array * MessageBuilder::attachments() void MessageBuilder::addAttachment(Attachment * attachment) { + if (attachment == NULL) { + return; + } if (mAttachments == NULL) { mAttachments = new Array(); } @@ -598,6 +601,9 @@ Array * MessageBuilder::relatedAttachments() void MessageBuilder::addRelatedAttachment(Attachment * attachment) { + if (attachment == NULL) { + return; + } if (mRelatedAttachments == NULL) { mRelatedAttachments = new Array(); } diff --git a/src/core/rfc822/MCMessageParser.cc b/src/core/rfc822/MCMessageParser.cc index 0366d597..d5bf84e7 100644 --- a/src/core/rfc822/MCMessageParser.cc +++ b/src/core/rfc822/MCMessageParser.cc @@ -30,6 +30,25 @@ void MessageParser::init() MessageParser::MessageParser(Data * data) { init(); + + const char * start = NULL; + unsigned int length = 0; + if (data->length() > 5) { + if (strncmp(data->bytes(), "From ", 5) == 0) { + start = data->bytes(); + for(unsigned int i = 0 ; i < data->length() ; i ++) { + if (start[i] == '\n') { + start = start + i + 1; + length = data->length() - (i + 1); + break; + } + } + } + } + if (start != NULL) { + data = Data::dataWithBytes(start, length); + } + mData = (Data *) data->retain(); mailmessage * msg; |