Revision 57e4ed2b
Added by jahoti about 2 years ago
background/policy_injector.js | ||
---|---|---|
16 | 16 |
* IMPORT gen_unique |
17 | 17 |
* IMPORT gen_nonce |
18 | 18 |
* IMPORT is_privileged_url |
19 |
* IMPORT url_item |
|
20 | 19 |
* IMPORT url_extract_target |
21 | 20 |
* IMPORT sign_policy |
22 | 21 |
* IMPORT get_query_best |
common/misc.js | ||
---|---|---|
154 | 154 |
return gen_unique(time + policy); |
155 | 155 |
} |
156 | 156 |
|
157 |
/* Parse a CSP header */ |
|
158 |
function parse_csp(csp) { |
|
159 |
let directive, directive_array; |
|
160 |
let directives = {}; |
|
161 |
for (directive of csp.split(';')) { |
|
162 |
directive = directive.trim; |
|
163 |
if (directive === '') |
|
164 |
continue; |
|
165 |
|
|
166 |
directive_array = directive.split(/\s+/); |
|
167 |
directive = directive_array.shift(); |
|
168 |
/* The "true" case should never occur; nevertheless... */ |
|
169 |
directives[directive] = directive in directives ? |
|
170 |
directives[directive].concat(directive_array) : |
|
171 |
directive_array; |
|
172 |
} |
|
173 |
return directives; |
|
174 |
} |
|
175 |
|
|
157 | 176 |
/* |
158 | 177 |
* EXPORTS_START |
159 | 178 |
* EXPORT gen_nonce |
... | ... | |
165 | 184 |
* EXPORT nice_name |
166 | 185 |
* EXPORT open_in_settings |
167 | 186 |
* EXPORT is_privileged_url |
187 |
* EXPORT parse_csp |
|
168 | 188 |
* EXPORTS_END |
169 | 189 |
*/ |
content/main.js | ||
---|---|---|
9 | 9 |
/* |
10 | 10 |
* IMPORTS_START |
11 | 11 |
* IMPORT handle_page_actions |
12 |
* IMPORT url_item |
|
13 | 12 |
* IMPORT url_extract_target |
14 | 13 |
* IMPORT gen_unique |
15 | 14 |
* IMPORT gen_nonce |
Also available in: Unified diff
Remove unnecessary imports of url_item and add a CSP header-parsing function
The parsing function isn't used yet; however, it will eventually be as a less
destructive alternative to handling headers as indivisible units.