Skip to content

Commit 596edc5

Browse files
committed
parse attachments' name and filename
1 parent 51a8292 commit 596edc5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Net/src/MailMessage.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,27 @@ namespace
9898
NameValueCollection::ConstIterator end = header.end();
9999
PartSource* pPS = _pMsg->createPartStore(tmp,
100100
header[MailMessage::HEADER_CONTENT_TYPE],
101-
getFileNameFromDisp(it->second));
101+
getAttrFromHeader(header[MailMessage::HEADER_CONTENT_DISPOSITION], "filename"));
102102
poco_check_ptr (pPS);
103103
for (; it != end; ++it)
104104
{
105105
if (MailMessage::HEADER_CONTENT_DISPOSITION == it->first)
106106
{
107107
if (it->second == "inline") _pMsg->addContent(pPS, cte);
108-
else _pMsg->addAttachment("", pPS, cte);
108+
else _pMsg->addAttachment(getAttrFromHeader(header[MailMessage::HEADER_CONTENT_TYPE], "name"), pPS, cte);
109109
}
110-
111110
pPS->headers().set(it->first, it->second);
112111
}
113112
}
114113
}
115114

116115
private:
117-
std::string getFileNameFromDisp(const std::string& str)
116+
std::string getAttrFromHeader(const std::string& str, const std::string& attrName)
118117
{
119118
StringTokenizer st(str, ";=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
120119
StringTokenizer::Iterator it = st.begin();
121120
StringTokenizer::Iterator end = st.end();
122-
for (; it != end; ++it) { if (*it == "filename") break; }
121+
for (; it != end; ++it) { if (*it == attrName) break; }
123122
if (it != end)
124123
{
125124
++it;

0 commit comments

Comments
 (0)