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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 unsigned start = pos; | 100 unsigned start = pos; |
101 unsigned len = str.length(); | 101 unsigned len = str.length(); |
102 while (pos < len) { | 102 while (pos < len) { |
103 if (str[pos] == ' ' || str[pos] == '\t' || str[pos] == ';') | 103 if (str[pos] == ' ' || str[pos] == '\t' || str[pos] == ';') |
104 break; | 104 break; |
105 ++pos; | 105 ++pos; |
106 } | 106 } |
107 return pos != start; | 107 return pos != start; |
108 } | 108 } |
109 | 109 |
110 // See RFC 2616, Section 4.2. | |
hiroshige
2015/08/27 11:38:08
Removing this comment might be better, because isV
shiva.jm
2015/09/01 08:26:51
Done.
| |
110 bool isValidHTTPHeaderValue(const String& name) | 111 bool isValidHTTPHeaderValue(const String& name) |
111 { | 112 { |
112 // FIXME: This should really match name against | 113 // FIXME: This should really match name against |
113 // field-value in section 4.2 of RFC 2616. | 114 // field-value in section 4.2 of RFC 2616. |
114 | 115 |
115 return name.containsOnlyLatin1() && !name.contains('\r') && !name.contains(' \n') && !name.contains(static_cast<UChar>('\0')); | 116 return name.containsOnlyLatin1() && !name.contains('\r') && !name.contains(' \n') && !name.contains(static_cast<UChar>('\0')); |
116 } | 117 } |
117 | 118 |
118 // See RFC 2616, Section 2.2. | 119 // See RFC 7230, Section 3.2.3. |
hiroshige
2015/08/27 11:38:08
Please add a comment that this function checks whe
shiva.jm
2015/09/01 08:26:51
Done.
| |
119 bool isValidHTTPToken(const String& characters) | 120 bool isValidHTTPHeaderValueForFetch(const String& value) |
120 { | 121 { |
hiroshige
2015/08/27 11:38:08
Please add:
if (value.isEmpty())
return false;
shiva.jm
2015/09/01 08:26:51
Done.
| |
121 if (characters.isEmpty()) | 122 UChar c = value[0]; |
hiroshige
2015/08/27 11:38:08
c -> firstCharacter, as tkent@ commented.
shiva.jm
2015/09/01 08:26:51
Done.
| |
123 if (c == ' ' || c == '\t') | |
122 return false; | 124 return false; |
123 for (unsigned i = 0; i < characters.length(); ++i) { | 125 |
124 UChar c = characters[i]; | 126 c = value[value.length() - 1]; |
hiroshige
2015/08/27 11:38:08
c -> UChar lastCharacter, as tkent@ commented.
shiva.jm
2015/09/01 08:26:51
Done.
| |
127 if (c == ' ' || c == '\t') | |
128 return false; | |
129 | |
130 for (unsigned i = 0; i < value.length(); ++i) { | |
131 c = value[i]; | |
hiroshige
2015/08/27 11:38:08
c -> UChar c.
shiva.jm
2015/09/01 08:26:51
Done.
| |
132 if (c == 0x7F || c > 0xFF || (c < 0x20 && c != '\t')) | |
133 return false; | |
134 } | |
135 | |
136 return true; | |
137 } | |
138 | |
139 // See RFC 7230, Section 3.2.6. | |
140 bool isValidHTTPToken(const String& value) | |
hiroshige
2015/08/27 11:38:08
Please retain the name of |characters| instead of
shiva.jm
2015/09/01 08:26:51
Done.
| |
141 { | |
142 if (value.isEmpty()) | |
143 return false; | |
144 for (unsigned i = 0; i < value.length(); ++i) { | |
145 UChar c = value[i]; | |
125 if (c <= 0x20 || c >= 0x7F | 146 if (c <= 0x20 || c >= 0x7F |
126 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' | 147 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' |
127 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' | 148 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' |
128 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' | 149 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' |
129 || c == '{' || c == '}') | 150 || c == '{' || c == '}') |
130 return false; | 151 return false; |
131 } | 152 } |
132 return true; | 153 return true; |
133 } | 154 } |
134 | 155 |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 | 890 |
870 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) | 891 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) |
871 { | 892 { |
872 Vector<String> results; | 893 Vector<String> results; |
873 headerValue.split(",", results); | 894 headerValue.split(",", results); |
874 for (auto& value : results) | 895 for (auto& value : results) |
875 headerSet.add(value.stripWhiteSpace(isWhitespace)); | 896 headerSet.add(value.stripWhiteSpace(isWhitespace)); |
876 } | 897 } |
877 | 898 |
878 } | 899 } |
OLD | NEW |