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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPParsersTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
5 * Copyright (C) 2009 Google Inc. All rights reserved. 5 * Copyright (C) 2009 Google Inc. All rights reserved.
6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 bool isValidHTTPHeaderValue(const String& name) 110 bool isValidHTTPHeaderValue(const String& name)
111 { 111 {
112 // FIXME: This should really match name against 112 // FIXME: This should really match name against
113 // field-value in section 4.2 of RFC 2616. 113 // field-value in section 4.2 of RFC 2616.
114 114
115 return name.containsOnlyLatin1() && !name.contains('\r') && !name.contains(' \n') && !name.contains(static_cast<UChar>('\0')); 115 return name.containsOnlyLatin1() && !name.contains('\r') && !name.contains(' \n') && !name.contains(static_cast<UChar>('\0'));
116 } 116 }
117 117
118 // See RFC 2616, Section 2.2. 118 // See RFC 7230, Section 3.2.
119 // Checks whether |value| matches field-content in RFC 7230.
120 // link: http://tools.ietf.org/html/rfc7230#section-3.2
121 bool isValidHTTPFieldContentRFC7230(const String& value)
122 {
123 if (value.isEmpty())
124 return false;
125
126 UChar firstCharacter = value[0];
127 if (firstCharacter == ' ' || firstCharacter == '\t')
128 return false;
129
130 UChar lastCharacter = value[value.length() - 1];
131 if (lastCharacter == ' ' || lastCharacter == '\t')
132 return false;
133
134 for (unsigned i = 0; i < value.length(); ++i) {
135 UChar c = value[i];
136 // TODO(mkwst): Extract this character class to a central location, http s://crbug.com/527324.
137 if (c == 0x7F || c > 0xFF || (c < 0x20 && c != '\t'))
138 return false;
139 }
140
141 return true;
142 }
143
144 // See RFC 7230, Section 3.2.6.
119 bool isValidHTTPToken(const String& characters) 145 bool isValidHTTPToken(const String& characters)
120 { 146 {
121 if (characters.isEmpty()) 147 if (characters.isEmpty())
122 return false; 148 return false;
123 for (unsigned i = 0; i < characters.length(); ++i) { 149 for (unsigned i = 0; i < characters.length(); ++i) {
124 UChar c = characters[i]; 150 UChar c = characters[i];
125 if (c <= 0x20 || c >= 0x7F 151 if (c <= 0x20 || c >= 0x7F
126 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' 152 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@'
127 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' 153 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"'
128 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' 154 || c == '/' || c == '[' || c == ']' || c == '?' || c == '='
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 895
870 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) 896 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet)
871 { 897 {
872 Vector<String> results; 898 Vector<String> results;
873 headerValue.split(",", results); 899 headerValue.split(",", results);
874 for (auto& value : results) 900 for (auto& value : results)
875 headerSet.add(value.stripWhiteSpace(isWhitespace)); 901 headerSet.add(value.stripWhiteSpace(isWhitespace));
876 } 902 }
877 903
878 } 904 }
OLDNEW
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPParsersTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698