@@ -1089,6 +1089,10 @@ int Multipart::multipart_complete(std::string *error) {
1089
1089
#ifndef NO_LOGS
1090
1090
debug (1 , " Multipart: Final boundary missing." );
1091
1091
#endif
1092
+ m_flag_unmatched_boundary = 1 ;
1093
+ m_transaction->m_variableMultipartUnmatchedBoundary .set (
1094
+ std::to_string (m_flag_unmatched_boundary),
1095
+ m_transaction->m_variableOffset );
1092
1096
error->assign (" Multipart: Final boundary missing." );
1093
1097
return false ;
1094
1098
}
@@ -1424,6 +1428,8 @@ bool Multipart::process(const std::string& data, std::string *error,
1424
1428
unsigned int inleft = data.size ();
1425
1429
size_t z = 0 ;
1426
1430
1431
+ std::list<std::string> boundaries;
1432
+
1427
1433
if (data.size () == 0 ) return true ;
1428
1434
m_seen_data = true ;
1429
1435
@@ -1574,7 +1580,13 @@ bool Multipart::process(const std::string& data, std::string *error,
1574
1580
return false ;
1575
1581
}
1576
1582
1577
- m_flag_unmatched_boundary = 1 ;
1583
+ bool contains = std::find (boundaries.begin (), boundaries.end (), p) != boundaries.end ();
1584
+ if (contains) {
1585
+ debug (4 , " Multipart: unmatched boundary... '" + std::string (p) + " '." );
1586
+ m_flag_unmatched_boundary = 1 ;
1587
+ } else {
1588
+ boundaries.push_back (p);
1589
+ }
1578
1590
}
1579
1591
} else { /* We do not think the buffer contains a boundary. */
1580
1592
/* Look into the buffer to see if there's anything
@@ -1589,6 +1601,7 @@ bool Multipart::process(const std::string& data, std::string *error,
1589
1601
&& (p[i + 1 ] == ' -' )) {
1590
1602
if (strncmp (p + i + 2 , m_boundary.c_str (),
1591
1603
m_boundary.size ()) == 0 ) {
1604
+ debug (4 , " Multipart: unmatched boundary." );
1592
1605
m_flag_unmatched_boundary = 1 ;
1593
1606
break ;
1594
1607
}
0 commit comments