diff --git a/src/internfile/mh_mail.cpp b/src/internfile/mh_mail.cpp index 60b9c089..643b20a8 100644 --- a/src/internfile/mh_mail.cpp +++ b/src/internfile/mh_mail.cpp @@ -51,21 +51,23 @@ static const string cstr_mail_charset("charset"); MimeHandlerMail::MimeHandlerMail(RclConfig *cnf, const string &id) : RecollFilter(cnf, id), m_bincdoc(0), m_fd(-1), m_stream(0), m_idx(-1) { - // Look for additional headers to be processed as per config: vector hdrnames = m_config->getFieldSectNames("mail"); if (hdrnames.empty()) return; - for (vector::const_iterator it = hdrnames.begin(); - it != hdrnames.end(); it++) { - (void)m_config->getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]); + for (const auto& nm : hdrnames) { + (void)m_config->getFieldConfParam(nm, "mail", m_addProcdHdrs[nm]); } } MimeHandlerMail::~MimeHandlerMail() { - clear(); + if (m_fd >= 0) { + close(m_fd); + m_fd = -1; + } } + void MimeHandlerMail::clear_impl() { delete m_bincdoc; m_bincdoc = 0; @@ -77,9 +79,8 @@ void MimeHandlerMail::clear_impl() m_idx = -1; m_startoftext = 0; m_subject.erase(); - for (vector::iterator it = m_attachments.begin(); - it != m_attachments.end(); it++) { - delete *it; + for (auto attp : m_attachments) { + delete attp; } m_attachments.clear(); } @@ -391,10 +392,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth) if (!m_addProcdHdrs.empty()) { for (auto& it : m_addProcdHdrs) { if (!it.second.empty() && doc->h.getFirstHeader(it.first, hi)) { - // Email headers are supposedly ASCII, but we force - // transcode to UTF-8 anyway so that at least partial - // indexing can be done if there are 8bit chars in there. - transcode(hi.getValue(), m_metaData[it.second], "CP1252", "UTF-8"); + rfc2047_decode(hi.getValue(), m_metaData[it.second]); } } } diff --git a/src/internfile/mh_mail.h b/src/internfile/mh_mail.h index 9b62ffae..b0584f65 100644 --- a/src/internfile/mh_mail.h +++ b/src/internfile/mh_mail.h @@ -68,7 +68,7 @@ private: std::string::size_type m_startoftext; std::string m_subject; std::vector m_attachments; - // Additional headers to be process as per config + field name translation + // Additional headers to be processed as per config + field name translation std::map m_addProcdHdrs; };