Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Unified Diff: net/http/http_util.cc

Issue 7796025: Don't interpret embeded NULLs in a response header line as a line terminator. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc comments Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util.cc
===================================================================
--- net/http/http_util.cc (revision 100642)
+++ net/http/http_util.cc (working copy)
@@ -547,7 +547,7 @@
raw_headers.append(FindFirstNonLWS(line_begin, line_end), line_end);
} else {
// Terminate the previous line.
- raw_headers.push_back('\0');
+ raw_headers.push_back('\n');
// Copy the raw data to output.
raw_headers.append(line_begin, line_end);
@@ -557,7 +557,15 @@
}
}
- raw_headers.append("\0\0", 2);
+ raw_headers.append("\n\n", 2);
+
+ // Use '\0' as the canonical line terminator. If the input already contained
+ // any embeded '\0' characters we will strip them first to avoid interpreting
+ // them as line breaks.
+ raw_headers.erase(std::remove(raw_headers.begin(), raw_headers.end(), '\0'),
+ raw_headers.end());
+ std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
+
return raw_headers;
}
« no previous file with comments | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698