mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-27 19:10:20 +01:00 
			
		
		
		
	Merge pull request #879 from glacjay/attachment-names
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
	 Aleksandar Fabijanic
					Aleksandar Fabijanic