mercurial/hgweb/common.py
changeset 34643 f42dec9c976e
parent 34585 f28c85e29afc
child 34721 baee5512f262
equal deleted inserted replaced
34642:a679aa582d8d 34643:f42dec9c976e
    10 
    10 
    11 import base64
    11 import base64
    12 import errno
    12 import errno
    13 import mimetypes
    13 import mimetypes
    14 import os
    14 import os
    15 import uuid
       
    16 
    15 
    17 from .. import (
    16 from .. import (
    18     encoding,
    17     encoding,
    19     pycompat,
    18     pycompat,
    20     util,
    19     util,
   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