mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +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 filename;
|
||||
if (!contentDisp.empty())
|
||||
filename = getFileNameFromContentDisposition(contentDisp);
|
||||
filename = getParamFromHeader(contentDisp, "filename");
|
||||
if (filename.empty())
|
||||
filename = getNameFromContentType(contentType);
|
||||
filename = getParamFromHeader(contentType, "name");
|
||||
PartSource* pPS = _pMsg->createPartStore(tmp, contentType, filename);
|
||||
poco_check_ptr (pPS);
|
||||
NameValueCollection::ConstIterator it = header.begin();
|
||||
@ -121,27 +121,12 @@ namespace
|
||||
}
|
||||
|
||||
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 end = st.end();
|
||||
for (; it != end; ++it) { if (*it == "filename") 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; }
|
||||
for (; it != end; ++it) { if (*it == param) break; }
|
||||
if (it != end)
|
||||
{
|
||||
++it;
|
||||
|
Loading…
x
Reference in New Issue
Block a user