OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "extensions/common/csp_validator.h" | 5 #include "extensions/common/csp_validator.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "content/public/common/url_constants.h" |
| 13 #include "extensions/common/constants.h" |
12 | 14 |
13 namespace extensions { | 15 namespace extensions { |
14 | 16 |
15 namespace csp_validator { | 17 namespace csp_validator { |
16 | 18 |
17 namespace { | 19 namespace { |
18 | 20 |
19 const char kDefaultSrc[] = "default-src"; | 21 const char kDefaultSrc[] = "default-src"; |
20 const char kScriptSrc[] = "script-src"; | 22 const char kScriptSrc[] = "script-src"; |
21 const char kObjectSrc[] = "object-src"; | 23 const char kObjectSrc[] = "object-src"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (source == "'self'" || | 66 if (source == "'self'" || |
65 source == "'none'" || | 67 source == "'none'" || |
66 source == "http://127.0.0.1" || | 68 source == "http://127.0.0.1" || |
67 LowerCaseEqualsASCII(source, "blob:") || | 69 LowerCaseEqualsASCII(source, "blob:") || |
68 LowerCaseEqualsASCII(source, "filesystem:") || | 70 LowerCaseEqualsASCII(source, "filesystem:") || |
69 LowerCaseEqualsASCII(source, "http://localhost") || | 71 LowerCaseEqualsASCII(source, "http://localhost") || |
70 StartsWithASCII(source, "http://127.0.0.1:", false) || | 72 StartsWithASCII(source, "http://127.0.0.1:", false) || |
71 StartsWithASCII(source, "http://localhost:", false) || | 73 StartsWithASCII(source, "http://localhost:", false) || |
72 StartsWithASCII(source, "https://", true) || | 74 StartsWithASCII(source, "https://", true) || |
73 StartsWithASCII(source, "chrome://", true) || | 75 StartsWithASCII(source, "chrome://", true) || |
74 StartsWithASCII(source, "chrome-extension://", true) || | 76 StartsWithASCII(source, |
| 77 std::string(extensions::kExtensionScheme) + |
| 78 content::kStandardSchemeSeparator, |
| 79 true) || |
75 StartsWithASCII(source, "chrome-extension-resource:", true)) { | 80 StartsWithASCII(source, "chrome-extension-resource:", true)) { |
76 continue; | 81 continue; |
77 } | 82 } |
78 | 83 |
79 // crbug.com/146487 | 84 // crbug.com/146487 |
80 if (type == Manifest::TYPE_EXTENSION || | 85 if (type == Manifest::TYPE_EXTENSION || |
81 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { | 86 type == Manifest::TYPE_LEGACY_PACKAGED_APP) { |
82 if (source == "'unsafe-eval'") | 87 if (source == "'unsafe-eval'") |
83 continue; | 88 continue; |
84 } | 89 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 198 } |
194 } | 199 } |
195 } | 200 } |
196 | 201 |
197 return seen_sandbox; | 202 return seen_sandbox; |
198 } | 203 } |
199 | 204 |
200 } // namespace csp_validator | 205 } // namespace csp_validator |
201 | 206 |
202 } // namespace extensions | 207 } // namespace extensions |
OLD | NEW |