Browse Source

handle "multipart/alternative"

afl-fuzzing
Roker 3 years ago
parent
commit
e579ecfd92
1 changed files with 21 additions and 6 deletions
  1. +21
    -6
      src/bodyparser.cc

+ 21
- 6
src/bodyparser.cc View File

@ -108,8 +108,7 @@ struct has_mimetype
bool operator()(const Message& m) const
{
MimeHeaders mh{m.headers};
return mh.mime_type() == mt;
return m.mh.mime_type() == mt;
}
const char* mt;
@ -152,14 +151,30 @@ void parse_body(message* msg, const HeaderSection& headers, const BodyLines& bod
if(mh.subtype == "alternative")
{
auto first_text = std::find_if(vm.begin(), vm.end(), has_mimetype("text/plain") );
auto first_html = std::find_if(vm.begin(), vm.end(), has_mimetype("text/html") );
auto first_text = std::find_if(vm.cbegin(), vm.cend(), has_mimetype("text/plain") );
if(first_text != vm.end())
{
const sv charset = header_value( first_text->mh.tparams, "charset" );
msg->longmsg = create_string(first_text->body, charset, first_text->mh.decoder );
}
auto first_html = std::find_if(vm.cbegin(), vm.cend(), has_mimetype("text/html") );
if(first_html != vm.end())
{
const sv charset = header_value( first_html->mh.tparams, "charset" );
msg->longmsg_formatted = create_string(first_html->body, charset, first_html->mh.decoder );
}
for(auto m = vm.cbegin(); m != vm.cend(); ++m)
{
if(m != first_text && m!=first_html)
{
add_attachment(msg, m->body, m->mh);
}
}
}else if(mh.subtype == "mixed")
{
for(const auto& m : vm)
{
MimeHeaders mh{m.headers};
add_attachment(msg, m.body, mh);
add_attachment(msg, m.body, m.mh);
}
}


Loading…
Cancel
Save