Chromium Code Reviews| 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 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; | |
|
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
| |
| 133 | |
| 134 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:
| |
| 135 UChar c = value[i]; | |
| 136 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
| |
| 137 return false; | |
| 138 } | |
| 139 | |
| 140 return true; | |
| 141 } | |
| 142 | |
| 143 // See RFC 7230, Section 3.2.6. | |
| 119 bool isValidHTTPToken(const String& characters) | 144 bool isValidHTTPToken(const String& characters) |
| 120 { | 145 { |
| 121 if (characters.isEmpty()) | 146 if (characters.isEmpty()) |
| 122 return false; | 147 return false; |
| 123 for (unsigned i = 0; i < characters.length(); ++i) { | 148 for (unsigned i = 0; i < characters.length(); ++i) { |
| 124 UChar c = characters[i]; | 149 UChar c = characters[i]; |
| 125 if (c <= 0x20 || c >= 0x7F | 150 if (c <= 0x20 || c >= 0x7F |
| 126 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' | 151 || c == '(' || c == ')' || c == '<' || c == '>' || c == '@' |
| 127 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' | 152 || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' |
| 128 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' | 153 || c == '/' || c == '[' || c == ']' || c == '?' || c == '=' |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 | 894 |
| 870 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) | 895 void parseCommaDelimitedHeader(const String& headerValue, CommaDelimitedHeaderSe t& headerSet) |
| 871 { | 896 { |
| 872 Vector<String> results; | 897 Vector<String> results; |
| 873 headerValue.split(",", results); | 898 headerValue.split(",", results); |
| 874 for (auto& value : results) | 899 for (auto& value : results) |
| 875 headerSet.add(value.stripWhiteSpace(isWhitespace)); | 900 headerSet.add(value.stripWhiteSpace(isWhitespace)); |
| 876 } | 901 } |
| 877 | 902 |
| 878 } | 903 } |
| OLD | NEW |