mercurial/hgweb/request.py
branchstable
changeset 50817 9ed281bbf864
parent 49846 fda5a4b853ab
child 51725 278af66e6595
equal deleted inserted replaced
50815:04d5cde28a7f 50817:9ed281bbf864
     9 
     9 
    10 # import wsgiref.validate
    10 # import wsgiref.validate
    11 
    11 
    12 from ..thirdparty import attr
    12 from ..thirdparty import attr
    13 from .. import (
    13 from .. import (
    14     encoding,
       
    15     error,
    14     error,
    16     pycompat,
    15     pycompat,
    17     util,
    16     util,
    18 )
    17 )
    19 from ..utils import (
    18 from ..utils import (
   165     # \00000-\000FF. We deal with bytes in Mercurial, so mass convert string
   164     # \00000-\000FF. We deal with bytes in Mercurial, so mass convert string
   166     # keys and values to bytes.
   165     # keys and values to bytes.
   167     def tobytes(s):
   166     def tobytes(s):
   168         if not isinstance(s, str):
   167         if not isinstance(s, str):
   169             return s
   168             return s
   170         if pycompat.iswindows:
   169         return s.encode('iso8859-1')
   171             # This is what mercurial.encoding does for os.environ on
       
   172             # Windows.
       
   173             return encoding.strtolocal(s)
       
   174         else:
       
   175             # This is what is documented to be used for os.environ on Unix.
       
   176             return pycompat.fsencode(s)
       
   177 
   170 
   178     env = {tobytes(k): tobytes(v) for k, v in env.items()}
   171     env = {tobytes(k): tobytes(v) for k, v in env.items()}
   179 
   172 
   180     # Some hosting solutions are emulating hgwebdir, and dispatching directly
   173     # Some hosting solutions are emulating hgwebdir, and dispatching directly
   181     # to an hgweb instance using this environment variable.  This was always
   174     # to an hgweb instance using this environment variable.  This was always