OLD | NEW |
---|---|
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 Loading... | |
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 if (!value.containsOnlyLatin1()) | |
hiroshige
2015/09/04 05:23:42
I think this block is not needed (because this con
shiva.jm
2015/09/04 11:03:08
Done.
| |
127 return false; | |
128 | |
129 UChar firstCharacter = value[0]; | |
130 if (firstCharacter == ' ' || firstCharacter == '\t') | |
131 return false; | |
132 | |
133 UChar lastCharacter = value[value.length() - 1]; | |
134 if (lastCharacter == ' ' || lastCharacter == '\t') | |
135 return false; | |
136 | |
137 for (unsigned i = 0; i < value.length(); ++i) { | |
138 UChar c = value[i]; | |
139 // TODO(mkwst): Extract this character class to a central location, http s://crbug.com/527324. | |
140 if (c == 0x7F || c > 0xFF || (c < 0x20 && c != '\t')) | |
141 return false; | |
142 } | |
143 | |
144 return true; | |
145 } | |
146 | |
147 // See RFC 7230, Section 3.2.6. | |
119 bool isValidHTTPToken(const String& characters) | 148 bool isValidHTTPToken(const String& characters) |
120 { | 149 { |
121 if (characters.isEmpty()) | 150 if (characters.isEmpty()) |
122 return false; | 151 return false; |
123 for (unsigned i = 0; i < characters.length(); ++i) { | 152 for (unsigned i = 0; i < characters.length(); ++i) { |
124 UChar c = characters[i]; | 153 UChar c = characters[i]; |
125 if (c <= 0x20 || c >= 0x7F | 154 if (c <= 0x20 || c >= 0x7F |
126 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' | 155 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' |
127 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' | 156 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' |
128 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' | 157 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 | 898 |
870 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) | 899 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) |
871 { | 900 { |
872 Vector<String> results; | 901 Vector<String> results; |
873 headerValue.split(",", results); | 902 headerValue.split(",", results); |
874 for (auto& value : results) | 903 for (auto& value : results) |
875 headerSet.add(value.stripWhiteSpace(isWhitespace)); | 904 headerSet.add(value.stripWhiteSpace(isWhitespace)); |
876 } | 905 } |
877 | 906 |
878 } | 907 } |
OLD | NEW |