OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_COOKIES_PARSED_COOKIE_H_ | 5 #ifndef NET_COOKIES_PARSED_COOKIE_H_ |
6 #define NET_COOKIES_PARSED_COOKIE_H_ | 6 #define NET_COOKIES_PARSED_COOKIE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 static void ParseValue(std::string::const_iterator* it, | 96 static void ParseValue(std::string::const_iterator* it, |
97 const std::string::const_iterator& end, | 97 const std::string::const_iterator& end, |
98 std::string::const_iterator* value_start, | 98 std::string::const_iterator* value_start, |
99 std::string::const_iterator* value_end); | 99 std::string::const_iterator* value_end); |
100 | 100 |
101 // Same as the above functions, except the input is assumed to contain the | 101 // Same as the above functions, except the input is assumed to contain the |
102 // desired token/value and nothing else. | 102 // desired token/value and nothing else. |
103 static std::string ParseTokenString(const std::string& token); | 103 static std::string ParseTokenString(const std::string& token); |
104 static std::string ParseValueString(const std::string& value); | 104 static std::string ParseValueString(const std::string& value); |
105 | 105 |
| 106 // Is the string valid as the value of a cookie attribute? |
| 107 static bool IsValidCookieAttributeValue(const std::string& value); |
| 108 |
106 private: | 109 private: |
107 void ParseTokenValuePairs(const std::string& cookie_line); | 110 void ParseTokenValuePairs(const std::string& cookie_line); |
108 void SetupAttributes(); | 111 void SetupAttributes(); |
109 | 112 |
110 // Sets a key/value pair for a cookie. |index| has to point to one of the | 113 // Sets a key/value pair for a cookie. |index| has to point to one of the |
111 // |*_index_| fields in ParsedCookie and is updated to the position where | 114 // |*_index_| fields in ParsedCookie and is updated to the position where |
112 // the key/value pair is set in |pairs_|. Accordingly, |key| has to correspond | 115 // the key/value pair is set in |pairs_|. Accordingly, |key| has to correspond |
113 // to the token matching |index|. If |value| contains invalid characters, the | 116 // to the token matching |index|. If |value| contains invalid characters, the |
114 // cookie parameter is not changed and the function returns false. | 117 // cookie parameter is not changed and the function returns false. |
115 // If |value| is empty/false the key/value pair is removed. | 118 // If |value| is empty/false the key/value pair is removed. |
(...skipping 29 matching lines...) Expand all Loading... |
145 size_t httponly_index_; | 148 size_t httponly_index_; |
146 size_t same_site_index_; | 149 size_t same_site_index_; |
147 size_t priority_index_; | 150 size_t priority_index_; |
148 | 151 |
149 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); | 152 DISALLOW_COPY_AND_ASSIGN(ParsedCookie); |
150 }; | 153 }; |
151 | 154 |
152 } // namespace net | 155 } // namespace net |
153 | 156 |
154 #endif // NET_COOKIES_PARSED_COOKIE_H_ | 157 #endif // NET_COOKIES_PARSED_COOKIE_H_ |
OLD | NEW |