diff options
-rw-r--r-- | build-mac/mailcore2.xcodeproj/project.pbxproj | 4 | ||||
-rw-r--r-- | src/core/abstract/MCAbstractMessagePart.cc | 3 | ||||
-rw-r--r-- | src/core/basetypes/MCHTMLCleaner.cc | 20 | ||||
-rw-r--r-- | src/core/basetypes/MCString.cc | 49 | ||||
-rw-r--r-- | src/core/renderer/MCHTMLRenderer.cpp | 5 | ||||
-rw-r--r-- | src/core/renderer/MCRenderer.h | 2 | ||||
-rw-r--r-- | src/core/rfc822/MCAttachment.cc | 1 | ||||
-rw-r--r-- | src/core/rfc822/MCMessageParser.cc | 8 | ||||
-rw-r--r-- | src/core/rfc822/MCMessageParser.h | 1 |
9 files changed, 57 insertions, 36 deletions
diff --git a/build-mac/mailcore2.xcodeproj/project.pbxproj b/build-mac/mailcore2.xcodeproj/project.pbxproj index 532f2112..7ae406ef 100644 --- a/build-mac/mailcore2.xcodeproj/project.pbxproj +++ b/build-mac/mailcore2.xcodeproj/project.pbxproj @@ -643,6 +643,7 @@ C6A81BF01707806800882C15 /* MCOSMTPOperation.h in CopyFiles */, C6A81BED1707806100882C15 /* MCOPOPFetchMessagesOperation.h in CopyFiles */, C6A81BEF1707806600882C15 /* MCOSMTPSendOperation.h in CopyFiles */, + C63CD68916BE1BC100DB18F1 /* MCDateFormatter.h in CopyFiles */, C6F61FAE170288640073032E /* MCOMessageBuilder.h in CopyFiles */, C6F61FB61702B5290073032E /* MCOIMAPBaseOperation.h in CopyFiles */, C6F61FB21702886B0073032E /* MCORFC822.h in CopyFiles */, @@ -690,7 +691,6 @@ C64BB25616FD333C000DB34C /* MCOAbstractMessage.h in CopyFiles */, C64BB24716EEFCB9000DB34C /* MCOAbstract.h in CopyFiles */, C64BB24A16EEFCBF000DB34C /* MCOAbstractMultipart.h in CopyFiles */, - C63CD68916BE1BC100DB18F1 /* MCDateFormatter.h in CopyFiles */, C64BB24916EEFCBE000DB34C /* MCOAbstractMessagePart.h in CopyFiles */, C64BB24D16EEFCC4000DB34C /* MCOMessageHeader.h in CopyFiles */, C64BB24B16EEFCC1000DB34C /* MCOAbstractPart.h in CopyFiles */, @@ -807,6 +807,7 @@ C6A81BF1170780EC00882C15 /* MCOPOPSession.h in CopyFiles */, C6A81C04170A82F300882C15 /* MCIMAPSyncResult.h in CopyFiles */, C6BA2B0F1705F4E6003F0E9E /* MCOIMAPBaseOperation.h in CopyFiles */, + C6BA2B3E1705F4E6003F0E9E /* MCDateFormatter.h in CopyFiles */, C6A81BF2170780F900882C15 /* MCOPOPOperation.h in CopyFiles */, C6A81BF51707810C00882C15 /* MCOPOPFetchMessagesOperation.h in CopyFiles */, C6A81BF41707810900882C15 /* MCOPOPFetchMessageOperation.h in CopyFiles */, @@ -860,7 +861,6 @@ C6BA2B3B1705F4E6003F0E9E /* MCOAbstractMessage.h in CopyFiles */, C6BA2B3C1705F4E6003F0E9E /* MCOAbstract.h in CopyFiles */, C6BA2B3D1705F4E6003F0E9E /* MCOAbstractMultipart.h in CopyFiles */, - C6BA2B3E1705F4E6003F0E9E /* MCDateFormatter.h in CopyFiles */, C6BA2B3F1705F4E6003F0E9E /* MCOAbstractMessagePart.h in CopyFiles */, C6BA2B401705F4E6003F0E9E /* MCOMessageHeader.h in CopyFiles */, C6BA2B411705F4E6003F0E9E /* MCOAbstractPart.h in CopyFiles */, diff --git a/src/core/abstract/MCAbstractMessagePart.cc b/src/core/abstract/MCAbstractMessagePart.cc index 8ecd05f7..649fcc32 100644 --- a/src/core/abstract/MCAbstractMessagePart.cc +++ b/src/core/abstract/MCAbstractMessagePart.cc @@ -8,6 +8,7 @@ void AbstractMessagePart::init() { mMainPart = NULL; mHeader = NULL; + setPartType(PartTypeMessage); } AbstractMessagePart::AbstractMessagePart() @@ -35,7 +36,7 @@ AbstractMessagePart::~AbstractMessagePart() String * AbstractMessagePart::description() { String * result = String::string(); - result->appendUTF8Format("<%s:%p %s>", className(), this, mMainPart->description()); + result->appendUTF8Format("<%s:%p %s>", className()->UTF8Characters(), this, mMainPart->description()->UTF8Characters()); return result; } diff --git a/src/core/basetypes/MCHTMLCleaner.cc b/src/core/basetypes/MCHTMLCleaner.cc index d8c63613..12f1371e 100644 --- a/src/core/basetypes/MCHTMLCleaner.cc +++ b/src/core/basetypes/MCHTMLCleaner.cc @@ -37,29 +37,33 @@ String * HTMLCleaner::cleanHTML(String * input) tidyOptSetBool(tdoc, TidyXhtmlOut, yes); tidySetCharEncoding(tdoc, "utf8"); tidyOptSetBool(tdoc, TidyForceOutput, yes); + //tidyOptSetValue(tdoc, TidyErrFile, "/dev/null"); + //tidyOptSetValue(tdoc, TidyOutFile, "/dev/null"); + tidyOptSetBool(tdoc, TidyShowWarnings, no); + tidyOptSetInt(tdoc, TidyShowErrors, 0); rc = tidySetErrorBuffer(tdoc, &errbuf); if ((rc > 1) || (rc < 0)) { - fprintf(stderr, "error tidySetErrorBuffer: %i\n", rc); - fprintf(stderr, "1:%s", errbuf.bp); + //fprintf(stderr, "error tidySetErrorBuffer: %i\n", rc); + //fprintf(stderr, "1:%s", errbuf.bp); //return NULL; } rc = tidyParseBuffer(tdoc, &docbuf); //MCLog("%s", MCUTF8(input)); if ((rc > 1) || (rc < 0)) { - fprintf(stderr, "error tidyParseBuffer: %i\n", rc); - fprintf(stderr, "1:%s", errbuf.bp); + //fprintf(stderr, "error tidyParseBuffer: %i\n", rc); + //fprintf(stderr, "1:%s", errbuf.bp); //return NULL; } rc = tidyCleanAndRepair(tdoc); if ((rc > 1) || (rc < 0)) { - fprintf(stderr, "error tidyCleanAndRepair: %i\n", rc); - fprintf(stderr, "1:%s", errbuf.bp); + //fprintf(stderr, "error tidyCleanAndRepair: %i\n", rc); + //fprintf(stderr, "1:%s", errbuf.bp); //return NULL; } rc = tidySaveBuffer(tdoc, &output); if ((rc > 1) || (rc < 0)) { - fprintf(stderr, "error tidySaveBuffer: %i\n", rc); - fprintf(stderr, "1:%s", errbuf.bp); + //fprintf(stderr, "error tidySaveBuffer: %i\n", rc); + //fprintf(stderr, "1:%s", errbuf.bp); } String * result = String::stringWithUTF8Characters((const char *) output.bp); diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 52fbbb1c..1ecceb39 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -1197,7 +1197,7 @@ unsigned int String::replaceOccurrencesOfString(String * occurrence, String * re location = u_strstr(p, occurrence->unicodeCharacters()); if (location == NULL) break; - p = location + 1; + p = location + occurrence->length(); count ++; } @@ -1248,7 +1248,7 @@ void String::deleteCharactersInRange(Range range) } int32_t count = mLength - (int32_t) (range.location + range.length); - u_memmove(&mUnicodeChars[range.location], &mUnicodeChars[range.location + range.length], count); + u_memmove(&mUnicodeChars[range.location], &mUnicodeChars[range.location + range.length], count + 1); } int String::locationOfString(String * occurrence) @@ -1301,7 +1301,6 @@ static void charactersParsed(void * context, } String * modifiedString; modifiedString = new String((const char *) ch, len); - //modifiedString->replaceOccurrencesOfString(MCSTR("\r\n"), MCSTR(" ")); modifiedString->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" ")); modifiedString->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" ")); modifiedString->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" ")); @@ -1488,12 +1487,14 @@ static void elementStarted(void * ctx, const xmlChar * name, const xmlChar ** at } else if (strcasecmp((const char *) name, "a") == 0) { AutoreleasePool * pool; - String * link; + String * link = NULL; HashMap * attributes; pool = new AutoreleasePool(); attributes = dictionaryFromAttributes(atts); - link = (String *) attributes->objectForKey(MCSTR("href")); + if (attributes != NULL) { + link = (String *) attributes->objectForKey(MCSTR("href")); + } if (link == NULL) link = MCSTR(""); @@ -1515,19 +1516,21 @@ static void elementStarted(void * ctx, const xmlChar * name, const xmlChar ** at pool = new AutoreleasePool(); attributes = dictionaryFromAttributes(atts); - style = (String *) attributes->objectForKey(MCSTR("style")); - if (style != NULL) { - if (style->locationOfString(MCSTR("margin: 0.0px 0.0px 0.0px 0.0px;")) != -1) { - hasSpacing = false; - } - else if (style->locationOfString(MCSTR("margin: 0px 0px 0px 0px;")) != -1) { - hasSpacing = false; - } - else if (style->locationOfString(MCSTR("margin: 0.0px;")) != -1) { - hasSpacing = false; - } - else if (style->locationOfString(MCSTR("margin: 0px;")) != -1) { - hasSpacing = false; + if (attributes != NULL) { + style = (String *) attributes->objectForKey(MCSTR("style")); + if (style != NULL) { + if (style->locationOfString(MCSTR("margin: 0.0px 0.0px 0.0px 0.0px;")) != -1) { + hasSpacing = false; + } + else if (style->locationOfString(MCSTR("margin: 0px 0px 0px 0px;")) != -1) { + hasSpacing = false; + } + else if (style->locationOfString(MCSTR("margin: 0.0px;")) != -1) { + hasSpacing = false; + } + else if (style->locationOfString(MCSTR("margin: 0px;")) != -1) { + hasSpacing = false; + } } } pool->release(); @@ -1569,9 +1572,13 @@ static void elementStarted(void * ctx, const xmlChar * name, const xmlChar ** at cite = false; pool = new AutoreleasePool(); attributes = dictionaryFromAttributes(atts); - type = (String *) attributes->objectForKey(MCSTR("type")); - if (type->caseInsensitiveCompare(MCSTR("cite")) == 0) { - cite = true; + if (attributes != NULL) { + type = (String *) attributes->objectForKey(MCSTR("type")); + if (type != NULL) { + if (type->caseInsensitiveCompare(MCSTR("cite")) == 0) { + cite = true; + } + } } pool->release(); diff --git a/src/core/renderer/MCHTMLRenderer.cpp b/src/core/renderer/MCHTMLRenderer.cpp index d168cd8e..71454a0e 100644 --- a/src/core/renderer/MCHTMLRenderer.cpp +++ b/src/core/renderer/MCHTMLRenderer.cpp @@ -219,7 +219,10 @@ String * htmlForAbstractPart(AbstractPart * part, htmlRendererContext * context) String * htmlForAbstractSinglePart(AbstractPart * part, htmlRendererContext * context) { - String * mimeType = part->mimeType()->lowercaseString(); + String * mimeType = NULL; + if (part->mimeType() != NULL) { + mimeType = part->mimeType()->lowercaseString(); + } MCAssert(mimeType != NULL); if (isTextPart(part, context)) { diff --git a/src/core/renderer/MCRenderer.h b/src/core/renderer/MCRenderer.h index a7b1993a..8495b329 100644 --- a/src/core/renderer/MCRenderer.h +++ b/src/core/renderer/MCRenderer.h @@ -11,5 +11,7 @@ #define __MAILCORE_MCRENDERER_H_ #include <MailCore/MCHTMLRendererCallback.h> +#include <MailCore/MCDateFormatter.h> +#include <MailCore/MCAddressDisplay.h> #endif diff --git a/src/core/rfc822/MCAttachment.cc b/src/core/rfc822/MCAttachment.cc index 0874d300..c75e689a 100644 --- a/src/core/rfc822/MCAttachment.cc +++ b/src/core/rfc822/MCAttachment.cc @@ -482,7 +482,6 @@ Attachment * Attachment::attachmentWithSingleMIME(struct mailmime * mime) content_id = single_fields.fld_id; loc = single_fields.fld_location; - MCLog("filename %s", filename); if (filename != NULL) { result->setFilename(String::stringByDecodingMIMEHeaderValue(filename)); } diff --git a/src/core/rfc822/MCMessageParser.cc b/src/core/rfc822/MCMessageParser.cc index 335ff43f..98982e93 100644 --- a/src/core/rfc822/MCMessageParser.cc +++ b/src/core/rfc822/MCMessageParser.cc @@ -14,6 +14,12 @@ MessageParser * MessageParser::messageParserWithData(Data * data) return (MessageParser *) parser->autorelease(); } +MessageParser * MessageParser::messageParserWithContentsOfFile(String * filename) +{ + Data * data = Data::dataWithContentsOfFile(filename); + return messageParserWithData(data); +} + void MessageParser::init() { mData = NULL; @@ -31,8 +37,6 @@ MessageParser::MessageParser(Data * data) msg = data_message_init(data->bytes(), data->length()); mailmessage_get_bodystructure(msg, &mime); mMainPart = (AbstractPart *) Attachment::attachmentsWithMIME(msg->msg_mime)->retain(); - MCLog("%s:%p ", MCUTF8(mMainPart->className()), mMainPart); - MCLog("%s:%p ", MCUTF8(mMainPart->description()), mMainPart); mMainPart->setMessage(this); header()->importIMFFields(msg->msg_fields); mailmessage_free(msg); diff --git a/src/core/rfc822/MCMessageParser.h b/src/core/rfc822/MCMessageParser.h index f5d043c5..4f13299d 100644 --- a/src/core/rfc822/MCMessageParser.h +++ b/src/core/rfc822/MCMessageParser.h @@ -15,6 +15,7 @@ namespace mailcore { class MessageParser : public AbstractMessage { public: static MessageParser * messageParserWithData(Data * data); + static MessageParser * messageParserWithContentsOfFile(String * filename); MessageParser(Data * data); virtual ~MessageParser(); |