mh_mail: use rfc2047 on additional headers requested by config. comments and small cleanups
This commit is contained in:
parent
0cdcaea437
commit
b4dfa40cbf
@ -51,21 +51,23 @@ static const string cstr_mail_charset("charset");
|
|||||||
MimeHandlerMail::MimeHandlerMail(RclConfig *cnf, const string &id)
|
MimeHandlerMail::MimeHandlerMail(RclConfig *cnf, const string &id)
|
||||||
: RecollFilter(cnf, id), m_bincdoc(0), m_fd(-1), m_stream(0), m_idx(-1)
|
: 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:
|
// Look for additional headers to be processed as per config:
|
||||||
vector<string> hdrnames = m_config->getFieldSectNames("mail");
|
vector<string> hdrnames = m_config->getFieldSectNames("mail");
|
||||||
if (hdrnames.empty())
|
if (hdrnames.empty())
|
||||||
return;
|
return;
|
||||||
for (vector<string>::const_iterator it = hdrnames.begin();
|
for (const auto& nm : hdrnames) {
|
||||||
it != hdrnames.end(); it++) {
|
(void)m_config->getFieldConfParam(nm, "mail", m_addProcdHdrs[nm]);
|
||||||
(void)m_config->getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MimeHandlerMail::~MimeHandlerMail()
|
MimeHandlerMail::~MimeHandlerMail()
|
||||||
{
|
{
|
||||||
clear();
|
if (m_fd >= 0) {
|
||||||
|
close(m_fd);
|
||||||
|
m_fd = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MimeHandlerMail::clear_impl()
|
void MimeHandlerMail::clear_impl()
|
||||||
{
|
{
|
||||||
delete m_bincdoc; m_bincdoc = 0;
|
delete m_bincdoc; m_bincdoc = 0;
|
||||||
@ -77,9 +79,8 @@ void MimeHandlerMail::clear_impl()
|
|||||||
m_idx = -1;
|
m_idx = -1;
|
||||||
m_startoftext = 0;
|
m_startoftext = 0;
|
||||||
m_subject.erase();
|
m_subject.erase();
|
||||||
for (vector<MHMailAttach*>::iterator it = m_attachments.begin();
|
for (auto attp : m_attachments) {
|
||||||
it != m_attachments.end(); it++) {
|
delete attp;
|
||||||
delete *it;
|
|
||||||
}
|
}
|
||||||
m_attachments.clear();
|
m_attachments.clear();
|
||||||
}
|
}
|
||||||
@ -391,10 +392,7 @@ bool MimeHandlerMail::processMsg(Binc::MimePart *doc, int depth)
|
|||||||
if (!m_addProcdHdrs.empty()) {
|
if (!m_addProcdHdrs.empty()) {
|
||||||
for (auto& it : m_addProcdHdrs) {
|
for (auto& it : m_addProcdHdrs) {
|
||||||
if (!it.second.empty() && doc->h.getFirstHeader(it.first, hi)) {
|
if (!it.second.empty() && doc->h.getFirstHeader(it.first, hi)) {
|
||||||
// Email headers are supposedly ASCII, but we force
|
rfc2047_decode(hi.getValue(), m_metaData[it.second]);
|
||||||
// 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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ private:
|
|||||||
std::string::size_type m_startoftext;
|
std::string::size_type m_startoftext;
|
||||||
std::string m_subject;
|
std::string m_subject;
|
||||||
std::vector<MHMailAttach *> m_attachments;
|
std::vector<MHMailAttach *> 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<std::string, std::string> m_addProcdHdrs;
|
std::map<std::string, std::string> m_addProcdHdrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user