From 9a42c8bca4af312b2506a8ae409f9c533946a5c7 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 13 Jul 2006 16:32:39 +0000 Subject: Fixed bugs in MHTML code + unit tests. --- src/messageParser.cpp | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'src/messageParser.cpp') diff --git a/src/messageParser.cpp b/src/messageParser.cpp index 018a5ed0..18809e82 100644 --- a/src/messageParser.cpp +++ b/src/messageParser.cpp @@ -100,7 +100,7 @@ void messageParser::parse(ref msg) findAttachments(msg); // Text parts - findTextParts(*msg, *msg); + findTextParts(msg, msg); } @@ -110,11 +110,11 @@ void messageParser::findAttachments(ref msg) } -void messageParser::findTextParts(const bodyPart& msg, const bodyPart& part) +void messageParser::findTextParts(ref msg, ref part) { // Handle the case in which the message is not multipart: if the body part is // "text/*", take this part. - if (part.getBody()->getPartCount() == 0) + if (part->getBody()->getPartCount() == 0) { mediaType type(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN); bool accept = false; @@ -122,7 +122,7 @@ void messageParser::findTextParts(const bodyPart& msg, const bodyPart& part) try { const contentTypeField& ctf = dynamic_cast - (*msg.getHeader()->findField(fields::CONTENT_TYPE)); + (*msg->getHeader()->findField(fields::CONTENT_TYPE)); const mediaType ctfType = *ctf.getValue().dynamicCast (); @@ -155,7 +155,7 @@ void messageParser::findTextParts(const bodyPart& msg, const bodyPart& part) } -bool messageParser::findSubTextParts(const bodyPart& msg, const bodyPart& part) +bool messageParser::findSubTextParts(ref msg, ref part) { // In general, all the text parts are contained in parallel in the same // parent part (or message). @@ -164,9 +164,9 @@ bool messageParser::findSubTextParts(const bodyPart& msg, const bodyPart& part) std::vector > textParts; - for (int i = 0 ; i < part.getBody()->getPartCount() ; ++i) + for (int i = 0 ; i < part->getBody()->getPartCount() ; ++i) { - const ref p = part.getBody()->getPartAt(i); + const ref p = part->getBody()->getPartAt(i); try { @@ -200,7 +200,7 @@ bool messageParser::findSubTextParts(const bodyPart& msg, const bodyPart& part) try { ref txtPart = textPartFactory::getInstance()->create(type); - txtPart->parse(msg, part, **p); + txtPart->parse(msg, part, *p); m_textParts.push_back(txtPart); } @@ -209,21 +209,16 @@ bool messageParser::findSubTextParts(const bodyPart& msg, const bodyPart& part) // Content-type not recognized. } } - - //return true; } - //else - { - bool found = false; + bool found = false; - for (int i = 0 ; !found && (i < part.getBody()->getPartCount()) ; ++i) - { - found = findSubTextParts(msg, *part.getBody()->getPartAt(i)); - } - - return found; + for (int i = 0 ; !found && (i < part->getBody()->getPartCount()) ; ++i) + { + found = findSubTextParts(msg, part->getBody()->getPartAt(i)); } + + return found; } -- cgit v1.2.3