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

Unified Diff: Source/platform/network/HTTPParsers.cpp

Issue 1018903002: Show deprecation warnings for header values in XHR according to RFC 7230 (Closed) 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
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/network/HTTPParsers.cpp
diff --git a/Source/platform/network/HTTPParsers.cpp b/Source/platform/network/HTTPParsers.cpp
index 7e344e63987720c6f3eae4b6f1d67a57122eaf00..ebc54f0639c1fc950a079f54cc80f842fa6de119 100644
--- a/Source/platform/network/HTTPParsers.cpp
+++ b/Source/platform/network/HTTPParsers.cpp
@@ -115,7 +115,32 @@ bool isValidHTTPHeaderValue(const String& name)
return name.containsOnlyLatin1() && !name.contains('\r') && !name.contains('\n') && !name.contains(static_cast<UChar>('\0'));
}
-// See RFC 2616, Section 2.2.
+// See RFC 7230, Section 3.2.
+// Checks whether |value| matches field-content in RFC 7230.
+// link: http://tools.ietf.org/html/rfc7230#section-3.2
+bool isValidHTTPFieldContentRFC7230(const String& value)
+{
+ if (value.isEmpty())
+ return false;
+
+ UChar firstCharacter = value[0];
+ if (firstCharacter == ' ' || firstCharacter == '\t')
+ return false;
+
+ UChar lastCharacter = value[value.length() - 1];
+ if (lastCharacter == ' ' || lastCharacter == '\t')
+ return false;
Mike West 2015/09/02 06:59:14 Why not just strip leading and trailing whitespace
shiva.jm 2015/09/02 09:37:12 striping of leading and trailing whitespace will b
+
+ for (unsigned i = 0; i < value.length(); ++i) {
Mike West 2015/09/02 06:59:14 Can you use the hot new C++11 loop syntax here? No
shiva.jm 2015/09/02 09:37:12 tried using for ( UChar c : value), but got error:
+ UChar c = value[i];
+ if (c == 0x7F || c > 0xFF || (c < 0x20 && c != '\t'))
Mike West 2015/09/02 06:59:14 This seems like it ought to already exist somewher
shiva.jm 2015/09/02 09:37:12 In these files same kind of check is done, WTFStri
+ return false;
+ }
+
+ return true;
+}
+
+// See RFC 7230, Section 3.2.6.
bool isValidHTTPToken(const String& characters)
{
if (characters.isEmpty())
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698