Fix Cookie header parsing issues

This commit is contained in:
martinhsv
2019-11-14 08:14:04 -08:00
committed by Felipe Zimmerle
parent 7ba77631f9
commit b8160cce6b
3 changed files with 58 additions and 5 deletions

View File

@@ -549,7 +549,18 @@ int Transaction::addRequestHeader(const std::string& key,
if (keyl == "cookie") {
size_t localOffset = m_variableOffset;
size_t pos;
std::vector<std::string> cookies = utils::string::ssplit(value, ';');
// Get rid of any optional whitespace after the cookie-string
// (i.e. after the end of the final cookie-pair)
if (!cookies.empty()) {
std::string& final_cookie_pair = cookies.back();
while (!final_cookie_pair.empty() && isspace(final_cookie_pair.back())) {
final_cookie_pair.pop_back();
}
}
for (const std::string &c : cookies) {
// skip empty substring, eg "Cookie: ;;foo=bar"
if (c.empty() == true) {