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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_messaging_host_manifest.cc

Issue 1878083002: Implement IsAsciiUpper and IsAsciiLower in base/strings/string_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h" 5 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/string_util.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
15 NativeMessagingHostManifest::~NativeMessagingHostManifest() {} 16 NativeMessagingHostManifest::~NativeMessagingHostManifest() {}
16 17
17 // static 18 // static
18 bool NativeMessagingHostManifest::IsValidName(const std::string& name) { 19 bool NativeMessagingHostManifest::IsValidName(const std::string& name) {
19 if (name.empty()) { 20 if (name.empty()) {
20 return false; 21 return false;
21 } 22 }
22 23
23 for (size_t i = 0; i < name.size(); ++i) { 24 for (size_t i = 0; i < name.size(); ++i) {
24 char c = name[i]; 25 char c = name[i];
25 26
26 // Verify that only the following characters are used: [a-z0-9._]. 27 // Verify that only the following characters are used: [a-z0-9._].
27 if (!((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || 28 if (!(base::IsAsciiLower(c) || base::IsAsciiDigit(c) || c == '.' ||
28 c == '.' || c == '_')) { 29 c == '_')) {
29 return false; 30 return false;
30 } 31 }
31 32
32 // Verify that dots are separated by other characters and that string 33 // Verify that dots are separated by other characters and that string
33 // doesn't begin or end with a dot. 34 // doesn't begin or end with a dot.
34 if (c == '.' && (i == 0 || name[i - 1] == '.' || i == name.size() - 1)) { 35 if (c == '.' && (i == 0 || name[i - 1] == '.' || i == name.size() - 1)) {
35 return false; 36 return false;
36 } 37 }
37 } 38 }
38 39
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return false; 132 return false;
132 } 133 }
133 134
134 allowed_origins_.AddPattern(pattern); 135 allowed_origins_.AddPattern(pattern);
135 } 136 }
136 137
137 return true; 138 return true;
138 } 139 }
139 140
140 } // namespace extensions 141 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698