From 28233060d4061b9bda791ee327931886509ea52e Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 16 Feb 2015 19:42:46 +0100 Subject: [PATCH] Skip word on unexpected error when fixing broken words. --- src/vmime/text.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vmime/text.cpp b/src/vmime/text.cpp index f506f660..930a9866 100644 --- a/src/vmime/text.cpp +++ b/src/vmime/text.cpp @@ -423,7 +423,17 @@ void text::fixBrokenWords(std::vector >& words) shared_ptr w2 = words[i + 1]; // Check whether the word is valid - bool valid = w1->getCharset().isValidText(w1->getBuffer(), NULL); + bool valid = false; + + try + { + w1->getCharset().isValidText(w1->getBuffer(), NULL); + } + catch (vmime::exceptions::charset_conv_error& e) + { + // Unknown charset or unexpected conversion error: assume word is valid + valid = true; + } // If the current word is not valid, try to grab some bytes // from the next word, to see whether it becomes valid.