mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 03:20:11 +01:00
parse attachments' name and filename
This commit is contained in:
@@ -98,28 +98,27 @@ namespace
|
||||
NameValueCollection::ConstIterator end = header.end();
|
||||
PartSource* pPS = _pMsg->createPartStore(tmp,
|
||||
header[MailMessage::HEADER_CONTENT_TYPE],
|
||||
getFileNameFromDisp(it->second));
|
||||
getAttrFromHeader(header[MailMessage::HEADER_CONTENT_DISPOSITION], "filename"));
|
||||
poco_check_ptr (pPS);
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (MailMessage::HEADER_CONTENT_DISPOSITION == it->first)
|
||||
{
|
||||
if (it->second == "inline") _pMsg->addContent(pPS, cte);
|
||||
else _pMsg->addAttachment("", pPS, cte);
|
||||
else _pMsg->addAttachment(getAttrFromHeader(header[MailMessage::HEADER_CONTENT_TYPE], "name"), pPS, cte);
|
||||
}
|
||||
|
||||
pPS->headers().set(it->first, it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::string getFileNameFromDisp(const std::string& str)
|
||||
std::string getAttrFromHeader(const std::string& str, const std::string& attrName)
|
||||
{
|
||||
StringTokenizer st(str, ";=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
|
||||
StringTokenizer::Iterator it = st.begin();
|
||||
StringTokenizer::Iterator end = st.end();
|
||||
for (; it != end; ++it) { if (*it == "filename") break; }
|
||||
for (; it != end; ++it) { if (*it == attrName) break; }
|
||||
if (it != end)
|
||||
{
|
||||
++it;
|
||||
|
||||
Reference in New Issue
Block a user