X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=parse.cpp;h=9c7fd10b2f0c87a4f01e1e6112d683c07ccd3e18;hp=bec742b8897e850795d2720fc4ab79cdf27e2628;hb=d34b94a858c08d64eddfb9c115719fd9129be933;hpb=58dd753c464d917dc446e2cbb4c01fd750d4eb87 diff --git a/parse.cpp b/parse.cpp index bec742b..9c7fd10 100644 --- a/parse.cpp +++ b/parse.cpp @@ -13,8 +13,23 @@ vector split_tokens(const string &line) vector ret; string current_token; + bool in_quote = false; + for (size_t i = 0; i < line.size(); ++i) { - if (isspace(line[i])) { + // Handle all escaped characters. + if (line[i] == '\\' && i < line.size() - 1) { + current_token.push_back(line[++i]); + continue; + } + + // Handle start and end quote. + if (line[i] == '"') { + in_quote = !in_quote; + continue; + } + + // Handle break. + if (isspace(line[i]) && !in_quote) { if (!current_token.empty()) { ret.push_back(current_token); } @@ -56,9 +71,9 @@ vector split_lines(const string &str) return ret; } -unordered_multimap extract_headers(const vector &lines, const string &log_context) +HTTPHeaderMultimap extract_headers(const vector &lines, const string &log_context) { - unordered_multimap parameters; + HTTPHeaderMultimap parameters; for (size_t i = 1; i < lines.size(); ++i) { size_t split = lines[i].find(":"); if (split == string::npos) {