OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/update_client/utils.h" | 5 #include "components/update_client/utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 bool IsValidBrand(const std::string& brand) { | 232 bool IsValidBrand(const std::string& brand) { |
233 const size_t kMaxBrandSize = 4; | 233 const size_t kMaxBrandSize = 4; |
234 if (brand.size() > kMaxBrandSize) | 234 if (brand.size() > kMaxBrandSize) |
235 return false; | 235 return false; |
236 | 236 |
237 return std::find_if_not(brand.begin(), brand.end(), [](char ch) { | 237 return std::find_if_not(brand.begin(), brand.end(), [](char ch) { |
238 return base::IsAsciiAlpha(ch); | 238 return base::IsAsciiAlpha(ch); |
239 }) == brand.end(); | 239 }) == brand.end(); |
240 } | 240 } |
241 | 241 |
| 242 bool IsValidAp(const std::string& ap) { |
| 243 const size_t kMaxApSize = 256; |
| 244 if (ap.size() > kMaxApSize) |
| 245 return false; |
| 246 |
| 247 return std::find_if_not(ap.begin(), ap.end(), [](char ch) { |
| 248 if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch)) |
| 249 return true; |
| 250 |
| 251 const char kSpecialChars[] = "+-_="; |
| 252 for (auto c : kSpecialChars) { |
| 253 if (c == ch) |
| 254 return true; |
| 255 } |
| 256 |
| 257 return false; |
| 258 }) == ap.end(); |
| 259 } |
| 260 |
242 void RemoveUnsecureUrls(std::vector<GURL>* urls) { | 261 void RemoveUnsecureUrls(std::vector<GURL>* urls) { |
243 DCHECK(urls); | 262 DCHECK(urls); |
244 urls->erase(std::remove_if( | 263 urls->erase(std::remove_if( |
245 urls->begin(), urls->end(), | 264 urls->begin(), urls->end(), |
246 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), | 265 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), |
247 urls->end()); | 266 urls->end()); |
248 } | 267 } |
249 | 268 |
250 } // namespace update_client | 269 } // namespace update_client |
OLD | NEW |