mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 08:46:41 +01:00
cleanup
This commit is contained in:
parent
d33b102259
commit
fa4e739860
@ -98,9 +98,9 @@ namespace
|
|||||||
std::string contentDisp = header.get(MailMessage::HEADER_CONTENT_DISPOSITION, "");
|
std::string contentDisp = header.get(MailMessage::HEADER_CONTENT_DISPOSITION, "");
|
||||||
std::string filename;
|
std::string filename;
|
||||||
if (!contentDisp.empty())
|
if (!contentDisp.empty())
|
||||||
filename = getFileNameFromContentDisposition(contentDisp);
|
filename = getParamFromHeader(contentDisp, "filename");
|
||||||
if (filename.empty())
|
if (filename.empty())
|
||||||
filename = getNameFromContentType(contentType);
|
filename = getParamFromHeader(contentType, "name");
|
||||||
PartSource* pPS = _pMsg->createPartStore(tmp, contentType, filename);
|
PartSource* pPS = _pMsg->createPartStore(tmp, contentType, filename);
|
||||||
poco_check_ptr (pPS);
|
poco_check_ptr (pPS);
|
||||||
NameValueCollection::ConstIterator it = header.begin();
|
NameValueCollection::ConstIterator it = header.begin();
|
||||||
@ -121,27 +121,12 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string getFileNameFromContentDisposition(const std::string& str)
|
std::string getParamFromHeader(const std::string& header, const std::string& param)
|
||||||
{
|
{
|
||||||
StringTokenizer st(str, ";=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
|
StringTokenizer st(header, ";=", 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 == param) break; }
|
||||||
if (it != end)
|
|
||||||
{
|
|
||||||
++it;
|
|
||||||
if (it == end) return "";
|
|
||||||
return *it;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getNameFromContentType(const std::string& str)
|
|
||||||
{
|
|
||||||
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 == "name") break; }
|
|
||||||
if (it != end)
|
if (it != end)
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user