diff options
-rw-r--r-- | src/core/basetypes/MCString.cc | 18 | ||||
-rw-r--r-- | src/core/basetypes/MCString.h | 2 | ||||
-rwxr-xr-x | src/core/imap/MCIMAPSession.cc | 11 | ||||
-rw-r--r-- | src/objc/utils/NSString+MCO.h | 1 | ||||
-rw-r--r-- | src/objc/utils/NSString+MCO.mm | 4 |
5 files changed, 26 insertions, 10 deletions
diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 054cbb80..3f0338db 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -1795,6 +1795,24 @@ String * String::flattenHTML() return flattenHTMLAndShowBlockquote(true); } +String * String::stripWhitespace() +{ + String *str = (String *)copy(); + + str->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\v"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\f"), MCSTR(" ")); + str->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" ")); + + while (str->replaceOccurrencesOfString(MCSTR(" "), MCSTR(" ")) > 0) { + /* do nothing */ + } + + return str; +} + + bool String::hasSuffix(String * suffix) { if (mLength >= suffix->mLength) { diff --git a/src/core/basetypes/MCString.h b/src/core/basetypes/MCString.h index 7fd07570..25439cf2 100644 --- a/src/core/basetypes/MCString.h +++ b/src/core/basetypes/MCString.h @@ -86,6 +86,8 @@ namespace mailcore { virtual String * flattenHTMLAndShowBlockquote(bool showBlockquote); virtual String * flattenHTMLAndShowBlockquoteAndLink(bool showBlockquote, bool showLink); + virtual String * stripWhitespace(); + virtual String * lastPathComponent(); virtual String * pathExtension(); virtual Data * dataUsingEncoding(const char * charset = NULL); diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 02e569dc..faabc522 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -3742,17 +3742,8 @@ String * IMAPSession::plainTextBodyRendering(IMAPMessage * message, String * fol } String * plainTextBodyString = htmlBodyString->flattenHTML(); - if (stripWhitespace) { - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\v"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\f"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" ")); - - while (plainTextBodyString->replaceOccurrencesOfString(MCSTR(" "), MCSTR(" ")) > 0) { - /* do nothing */ - } + return plainTextBodyString->stripWhitespace(); } return plainTextBodyString; diff --git a/src/objc/utils/NSString+MCO.h b/src/objc/utils/NSString+MCO.h index ac374bf7..71e99a44 100644 --- a/src/objc/utils/NSString+MCO.h +++ b/src/objc/utils/NSString+MCO.h @@ -34,6 +34,7 @@ namespace mailcore { - (NSString *) mco_htmlEncodedString; - (NSString *) mco_cleanedHTMLString; +- (NSString *) mco_strippedWhitespace; @end diff --git a/src/objc/utils/NSString+MCO.mm b/src/objc/utils/NSString+MCO.mm index e9933fab..68f75302 100644 --- a/src/objc/utils/NSString+MCO.mm +++ b/src/objc/utils/NSString+MCO.mm @@ -65,5 +65,9 @@ return [NSString mco_stringWithMCString:[self mco_mcString]->cleanedHTMLString()]; } +- (NSString *) mco_strippedWhitespace +{ + return [NSString mco_stringWithMCString:[self mco_mcString]->stripWhitespace()]; +} @end |