
    6h%                    6   S SK Jr  S SKrS SKrS SKrS SKrS SKrSSKJr  SSK	J
r
JrJrJrJr  \R                  rSrSrSrS	rS
rSrSrSrSrSrSr\R6                  rS rS r\/r " S S\5      r  " S S5      r!S r"S S jr#S r$S r%S r&S r'S!S jr(S r)S r*g)"    )annotationsN   )_)encodingpycompatscmutil	templaterutil      i0  i  i  i  i  i  i  i  i  c                   [        UR                  R                  S5      5      (       ab  U R                  nUR	                  SS5      nUR
                  nU(       a  [        X$U5      (       a  g[        S5      U-  nUR                  U5        g)Ns   access-hiddens   experimentals   server.allow-hidden-accessTsE   ignoring request to access hidden changeset by unauthorized user: %r
F)	boolqsparamsgetui
configlist
remoteuserismemberr   warn)reporeqr   allowusermsgs         8/usr/lib/python3/dist-packages/mercurial/hgweb/common.pyhashiddenaccessr   +   s    CLL-.// WWo/LM~~Xb.. / 	  GGCL    c                   UR                   nU R                  SS5      nU(       a<  U(       a%  [        U R                  R                  X45      (       a  [        [        S5      eU R                  SS5      nU(       a5  [        U R                  R                  X55      (       d  [        [        S5      eUS:X  a!  U R                  (       d  [        [        S5      eUS:X  d  Uc  gUS:X  a#  UR                  S	:w  a  S
n[        [        U5      eO"UR                  S:w  a  Sn[        [        U5      eU R                  SS5      (       a   UR                  S:w  a  [        [        S5      eU R                  SS5      nU(       a<  U(       a%  [        U R                  R                  X75      (       a  [        [        S5      eU R                  SS5      nU(       a%  [        U R                  R                  X85      (       d  [        [        S5      eg)zCheck permission for operation based on request data (including
authentication info). Return if op allowed, else raise an ErrorResponse
exception.   webs	   deny_reads   read not authorizeds
   allow_reads   pulls   pull not authorizedNs   uploads   PUTs   upload requires PUT requests   POSTs   push requires POST requests   push_ssls   httpss   ssl requireds	   deny_pushs   push not authorizeds
   allow-push)r   r   r   r   r   ErrorResponseHTTP_UNAUTHORIZED	allowpullmethodHTTP_METHOD_NOT_ALLOWED
configbool	urlschemeHTTP_FORBIDDEN)	hgwebr   opr   	deny_read
allow_readr   denyr   s	            r   
checkauthzr-   E   s   
 >>D  6I$(5::==$"J"J-/EFF!!&-8J8EJJMM4DD-/EFF	W}U__-/EFF	w"* 
Y::0C 7==   
w	+3S99 ,,(1JNO<<FL1DTXejjmmT@@-/EFFV]3Ehuzz}}d::-/EFF ;r   c                      \ rS rSrSS jrSrg)r    {   Nc                    Uc  [        U5      n[        R                  U [        R                  " U5      5        Xl        Uc  / nX0l        X l        g N)_statusmessage	Exception__init__r   sysstrcodeheadersmessage)selfr6   r8   r7   s       r   r4   ErrorResponse.__init__|   sC    ?$T*G4!9:	?Gr   )r6   r7   r8   )NN)__name__
__module____qualname____firstlineno__r4   __static_attributes__ r   r   r    r    {   s    r   r    c                  .    \ rS rSrSrS rSS jrS rSrg)	continuereader   a  File object wrapper to handle HTTP 100-continue.

This is used by servers so they automatically handle Expect: 100-continue
request headers. On first read of the request body, the 100 Continue
response is sent. This should trigger the client into actually sending
the request body.
c                *    Xl         X l        SU l        g )NF)f_write	continued)r9   rE   writes      r   r4   continuereader.__init__   s    r   c                    U R                   (       d  SU l         U R                  S5        U R                  R                  U5      $ )NTs   HTTP/1.1 100 Continue

)rG   rF   rE   read)r9   amts     r   rK   continuereader.read   s0    ~~!DNKK89vv{{3r   c                F    US;   a  [        U R                  U5      $ [        e)N)s   closes   readlines	   readliness   __iter__)getattrrE   AttributeError)r9   attrs     r   __getattr__continuereader.__getattr__   s"    EE4664((r   )rF   rG   rE   N))	r;   r<   r=   r>   __doc__r4   rK   rR   r?   r@   r   r   rB   rB      s    
 r   rB   c                    [         R                  R                  n[        R                  " UR                  U S5      S   5      $ )N)ErrorzUnknown errorr   )
httpserverbasehttprequesthandler	responsesr   bytesurlr   )r6   rZ   s     r   r2   r2      s5    11;;IY]]41KLQOPPr   c                2    SX=(       d    [        U 5      4-  $ )Ns   %d %s)r2   )r6   r8   s     r   statusmessager]      s    t<t(<===r   c                    [         R                  R                  X5      n[         R                  R                  U5      (       a  [         R                  " U5      $ [         R                  " U 5      $ )z%stat fn if it exists, spath otherwise)ospathjoinexistsstat)spathfncl_paths      r   get_statrg      sD    ggll5%G	ww~~gwwwwwu~r   c                <    [        U S5      [        R                     $ )Ns   00changelog.i)rg   rc   ST_MTIME)rd   s    r   	get_mtimerj      s    E+,T]];;r   c                    U R                  S5      nU He  nUS[        R                  [        R                  4;   d=  [        R                  U;   d)  [        R
                  c  MO  [        R
                  U;   d  Me    g   g)z9Determine if a path is safe to use for filesystem access.   /r   FT)splitr   oscurdirospardirosseposaltsep)r`   partsparts      r   
ispathsafert      sc    JJtES(++X->->??~~%  ,!!T)  r   c                   [        U5      (       d  gU(       dA  U =(       d    [        R                  " 5       nUb   [        R                  R                  US5      n[        R                  R
                  " UR                  S5      6 n[        R                  " [        R                  " [        R                  " U5      5      S   =(       d    S5      n[        R                  R                  X5      n [        R                  " U5        [        R                  " U5      nXcR2                  S'   UR5                  U5        U$ ! [         a    [!        ["        S5      e[$         a`  n	U	R&                  [&        R(                  :X  a  [!        [*        5      e[!        ["        [,        R.                  " U	R0                  5      5      eSn	A	ff = f)a  return a file inside directory with guessed Content-Type header

fname always uses '/' as directory separator and isn't allowed to
contain unusual path components.
Content-Type is guessed using the mimetypes module.
Return an empty string if fname is illegal or file not found.

Ns   staticrl   r   z
text/plains   illegal filenames   Content-Type)rt   r	   templatedirr_   r`   ra   rm   r   sysbytes	mimetypes
guess_typefsdecoderc   r
   readfile	TypeErrorr    HTTP_SERVER_ERROROSErrorerrnoENOENTHTTP_NOT_FOUNDr   
strtolocalstrerrorr7   setbodybytes)
templatepath	directoryfnamerestpfpathctr`   dataerrs
             r   
staticfiler      sH    e4Y224>R3IGGLL%++d+,E			X..u56q9J]
B 77<<	)D
}}T" $&KK TJ  D-/BCC 99$//!8#6#6s||#D 	s   0,D= =#G  AF;;G c              #     #    U (       a  U(       a  X-   U -  nX-   U -  S-  nOSnSn Uv   US-  nU (       a  X :  a  SU-
  nSnM  7f)z5count parity of horizontal stripes for easier reading   r   r@   )stripecountoffsetcountparitys       r   	paritygenr      s_     v%4&;6:

5/ZFE s   AAc                    U " SS5      =(       d8    U " SS5      =(       d(    [         R                  R                  S5      =(       d    S$ )zReturn repo contact information or empty string.

web.contact is the primary source, but if that is not set, try
ui.username or $EMAIL as a fallback to display something useful.
r   s   contacts   uis   usernames   EMAILr   )r   environr   )configs    r   get_contactr      sE     	vz" 	%%	)	 	r   c                    SSK nU R                  SSSS9nSnU(       aU  SU;   aO  [        R                  " UR	                  5       R
                  5      R                  S5      nUR                  SU5      nX#4$ )	a  Obtain the Content-Security-Policy header and nonce value.

Returns a 2-tuple of the CSP header value and the nonce value.

First value is ``None`` if CSP isn't enabled. Second value is ``None``
if CSP isn't enabled or if the CSP header doesn't need a nonce.
r   Nr   s   cspF)	untrusteds   %nonce%   =)uuidr   base64urlsafe_b64encodeuuid4bytesrstripreplace)r   r   cspnonces       r   	cspvaluesr     sk    .  ))FFe)
4CE
zS ((););<CCDIkk*e,:r   r1   )r   )+
__future__r   r   r   rx   r_   rc   i18nr    r   r   r   r	   r
   rX   HTTP_OKHTTP_CREATEDHTTP_NOT_MODIFIEDHTTP_BAD_REQUESTr!   r'   r   r$   HTTP_NOT_ACCEPTABLEHTTP_UNSUPPORTED_MEDIA_TYPEr}   r   r   r-   	permhooksr3   r    rB   r2   r]   rg   rj   rt   r   r   r   r   r@   r   r   <module>r      s    #    	    __

     !  4)Gf L		I 	 4Q
><%P""r   