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

Unified Diff: Source/core/fetch/FetchUtils.cpp

Issue 1288263003: Normalize and update the header value checks to RFC 7230 for Fetch Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
Index: Source/core/fetch/FetchUtils.cpp
diff --git a/Source/core/fetch/FetchUtils.cpp b/Source/core/fetch/FetchUtils.cpp
index 4139db3f4428bb32a9a66747453e79fd4ffcbf12..e21730289e3ef2469a8448159c29d42a9821c271 100644
--- a/Source/core/fetch/FetchUtils.cpp
+++ b/Source/core/fetch/FetchUtils.cpp
@@ -14,6 +14,11 @@
namespace blink {
+static bool isHTTPWhitespace(UChar chr)
yhirano 2015/09/09 04:41:50 Please place this function in the unnamed namespac
shiva.jm 2015/09/10 10:10:26 Done.
+{
+ return chr <= ' ' && (chr == ' ' || chr == '\n' || chr == '\t' || chr == '\r');
hiroshige 2015/09/09 07:01:48 "chr <= ' ' && " is not needed.
shiva.jm 2015/09/10 10:10:26 Done.
+}
+
namespace {
class ForbiddenHeaderNames {
@@ -189,4 +194,13 @@ AtomicString FetchUtils::normalizeMethod(const AtomicString& method)
return method;
}
+String FetchUtils::normalizeHeaderValue(const String& value)
+{
+ // https://fetch.spec.whatwg.org/#concept-header-value-normalize
+ // Strip leading and trailing whitespace from header value.
+ // HTTP whitespace bytes are 0x09, 0x0A, 0x0D, and 0x20.
+
+ return value.stripWhiteSpace(isHTTPWhitespace);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698