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