219 Returns a 2-tuple of the CSP header value and the nonce value. |
218 Returns a 2-tuple of the CSP header value and the nonce value. |
220 |
219 |
221 First value is ``None`` if CSP isn't enabled. Second value is ``None`` |
220 First value is ``None`` if CSP isn't enabled. Second value is ``None`` |
222 if CSP isn't enabled or if the CSP header doesn't need a nonce. |
221 if CSP isn't enabled or if the CSP header doesn't need a nonce. |
223 """ |
222 """ |
|
223 # Without demandimport, "import uuid" could have an immediate side-effect |
|
224 # running "ldconfig" on Linux trying to find libuuid. |
|
225 # With Python <= 2.7.12, that "ldconfig" is run via a shell and the shell |
|
226 # may pollute the terminal with: |
|
227 # |
|
228 # shell-init: error retrieving current directory: getcwd: cannot access |
|
229 # parent directories: No such file or directory |
|
230 # |
|
231 # Python >= 2.7.13 has fixed it by running "ldconfig" directly without a |
|
232 # shell (hg changeset a09ae70f3489). |
|
233 # |
|
234 # Moved "import uuid" from here so it's executed after we know we have |
|
235 # a sane cwd (i.e. after dispatch.py cwd check). |
|
236 # |
|
237 # We can move it back once we no longer need Python <= 2.7.12 support. |
|
238 import uuid |
|
239 |
224 # Don't allow untrusted CSP setting since it be disable protections |
240 # Don't allow untrusted CSP setting since it be disable protections |
225 # from a trusted/global source. |
241 # from a trusted/global source. |
226 csp = ui.config('web', 'csp', untrusted=False) |
242 csp = ui.config('web', 'csp', untrusted=False) |
227 nonce = None |
243 nonce = None |
228 |
244 |