OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/extensions/csp_validator.h" | 5 #include "chrome/common/extensions/csp_validator.h" |
6 | 6 |
7 #include "base/string_split.h" | 7 #include "base/string_split.h" |
8 #include "base/string_tokenizer.h" | 8 #include "base/string_tokenizer.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... | |
36 StringToLowerASCII(&source); | 36 StringToLowerASCII(&source); |
37 | 37 |
38 if (EndsWith(source, "*", true)) | 38 if (EndsWith(source, "*", true)) |
39 return false; | 39 return false; |
40 | 40 |
41 // We might need to relax this whitelist over time. | 41 // We might need to relax this whitelist over time. |
42 if (source == "'self'" || | 42 if (source == "'self'" || |
43 source == "'none'" || | 43 source == "'none'" || |
44 StartsWithASCII(source, "https://", true) || | 44 StartsWithASCII(source, "https://", true) || |
45 StartsWithASCII(source, "chrome://", true) || | 45 StartsWithASCII(source, "chrome://", true) || |
46 StartsWithASCII(source, "chrome-extension://", true)) { | 46 StartsWithASCII(source, "chrome-extension://", true) || |
47 StartsWithASCII(source, "chrome-extension-resource://", true)) { | |
abarth-chromium
2012/04/11 20:15:33
I can haz unit test?
abarth-chromium
2012/04/11 20:18:16
Note: If an extension uses chrome-extension-resour
Peng
2012/04/11 20:23:51
I will test it.
Peng
2012/04/11 20:23:51
That could be a problem. Any idea?
Maybe make the
| |
47 continue; | 48 continue; |
48 } | 49 } |
49 | 50 |
50 return false; | 51 return false; |
51 } | 52 } |
52 | 53 |
53 return true; // Empty values default to 'none', which is secure. | 54 return true; // Empty values default to 'none', which is secure. |
54 } | 55 } |
55 | 56 |
56 // Returns true if |directive_name| matches |status.directive_name|. | 57 // Returns true if |directive_name| matches |status.directive_name|. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 object_src_status.seen_in_policy; | 115 object_src_status.seen_in_policy; |
115 } | 116 } |
116 | 117 |
117 return default_src_status.seen_in_policy || | 118 return default_src_status.seen_in_policy || |
118 (script_src_status.seen_in_policy && object_src_status.seen_in_policy); | 119 (script_src_status.seen_in_policy && object_src_status.seen_in_policy); |
119 } | 120 } |
120 | 121 |
121 } // csp_validator | 122 } // csp_validator |
122 | 123 |
123 } // extensions | 124 } // extensions |
OLD | NEW |