Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: components/update_client/utils.cc

Issue 1872053002: Implement an API to allow passing an "ap" parameter to component updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/update_client/utils.h ('k') | components/update_client/utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/utils.cc
diff --git a/components/update_client/utils.cc b/components/update_client/utils.cc
index caa00cea2073b1cab34ba0dd42df24da940012c4..00123f450d3988c505941ffdc2350c29d5f17931 100644
--- a/components/update_client/utils.cc
+++ b/components/update_client/utils.cc
@@ -239,6 +239,25 @@ bool IsValidBrand(const std::string& brand) {
}) == brand.end();
}
+bool IsValidAp(const std::string& ap) {
+ const size_t kMaxApSize = 256;
+ if (ap.size() > kMaxApSize)
+ return false;
+
+ return std::find_if_not(ap.begin(), ap.end(), [](char ch) {
+ if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch))
+ return true;
+
+ const char kSpecialChars[] = "+-_=";
+ for (auto c : kSpecialChars) {
+ if (c == ch)
+ return true;
+ }
+
+ return false;
+ }) == ap.end();
+}
+
void RemoveUnsecureUrls(std::vector<GURL>* urls) {
DCHECK(urls);
urls->erase(std::remove_if(
« no previous file with comments | « components/update_client/utils.h ('k') | components/update_client/utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698