§
    	^µcl#  ã                   ó  — d dl Z d dlZd dlZd dlZd dlZddlmZmZ ddlm	Z	mZm
Z
mZ ej        ZdZdZdZdZd	Zd
ZdZdZdZdZdZd„ Zd„ ZegZ G d„ de¦  «        Z G d„ d¦  «        Zd„ Zdd„Zd„ Z d„ Z!d„ Z"d„ Z#d d„Z$d„ Z%d„ Z&dS )!é    Né   )ÚgetattrÚopen)ÚencodingÚpycompatÚ	templaterÚutiléÈ   éÉ   i0  i�  i‘  i“  i”  i•  i–  iŸ  iô  c                 ó   — |dgk    p||v S )zÒCheck if username is a member of userlist.

    If userlist has a single '*' member, all users are considered members.
    Can be overridden by extensions to provide more complex authorization
    schemes.
    ó   *© )ÚuiÚusernameÚuserlists      ú8/usr/lib/python3/dist-packages/mercurial/hgweb/common.pyÚismemberr   *   s   € ð ˜�vÒÐ5 ¨XÐ!5Ð5ó    c                 ó¶  — |j         }|                      dd¦  «        }|r2|rt          | j        j        ||¦  «        rt          t          d¦  «        ‚|                      dd¦  «        }|r0t          | j        j        ||¦  «        st          t          d¦  «        ‚|dk    r| j        st          t          d¦  «        ‚|dk    s|€dS |dk    r#|j        d	k    rd
}t          t          |¦  «        ‚n"|j        dk    rd}t          t          |¦  «        ‚|  
                    dd¦  «        r |j        dk    rt          t          d¦  «        ‚|                      dd¦  «        }|r2|rt          | j        j        ||¦  «        rt          t          d¦  «        ‚|                      dd¦  «        }|rt          | j        j        ||¦  «        st          t          d¦  «        ‚dS )zšCheck 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)Ú
remoteuserÚ
configlistr   Úrepor   ÚErrorResponseÚHTTP_UNAUTHORIZEDÚ	allowpullÚmethodÚHTTP_METHOD_NOT_ALLOWEDÚ
configboolÚ	urlschemeÚHTTP_FORBIDDEN)	ÚhgwebÚreqÚopÚuserÚ	deny_readÚ
allow_readÚmsgÚdenyÚallows	            r   Ú
checkauthzr+   4   s  € ð
 Œ>€Dà× Ò  ¨Ñ6Ô6€IØð G˜$ð G¥(¨5¬:¬=¸$À	Ñ"JÔ"Jð GÝÕ-Ð/EÑFÔFÐFà×!Ò! &¨-Ñ8Ô8€JØð G�8 E¤J¤M°4¸ÑDÔDð GÝÕ-Ð/EÑFÔFÐFà	ˆW‚}€}˜Uœ_€}ÝÕ-Ð/EÑFÔFÐFØ	ˆwŠˆ˜"˜*Øˆð 
ˆY‚€ØŒ:˜ÒÐØ0ˆCÝÕ 7¸Ñ=Ô=Ð=ð  ð 
Œ�wÒ	Ð	Ø+ˆÝÕ3°SÑ9Ô9Ð9ð ×Ò˜ Ñ,Ô,ð =°´À(Ò1JÐ1JÝ�N¨OÑ<Ô<Ð<à×Ò˜F LÑ1Ô1€DØð G�Tð G�X e¤j¤m°T¸4Ñ@Ô@ð GÝÕ-Ð/EÑFÔFÐFà×Ò˜V ]Ñ3Ô3€EØð G•h˜uœzœ}¨d°EÑ:Ô:ð GÝÕ-Ð/EÑFÔFÐFðGð Gr   c                   ó   — e Zd Zdd„ZdS )r   Nc                 ó´   — |€t          |¦  «        }t                               | t          j        |¦  «        ¦  «         || _        |€g }|| _        || _        d S ©N)Ú_statusmessageÚ	ExceptionÚ__init__r   ÚsysstrÚcodeÚheadersÚmessage)Úselfr3   r5   r4   s       r   r1   zErrorResponse.__init__k   sW   € Øˆ?Ý$ TÑ*Ô*ˆGÝ×Ò˜4¥¤°Ñ!9Ô!9Ñ:Ô:Ð:ØˆŒ	Øˆ?ØˆGØˆŒØˆŒˆˆr   )NN)Ú__name__Ú
__module__Ú__qualname__r1   r   r   r   r   r   j   s(   € € € € € ðð ð ð ð ð r   r   c                   ó&   — e Zd ZdZd„ Zdd„Zd„ ZdS )Úcontinuereadera.  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                 ó0   — || _         || _        d| _        d S )NF)ÚfÚ_writeÚ	continued)r6   r=   Úwrites      r   r1   zcontinuereader.__init__   s   € ØˆŒØˆŒØˆŒˆˆr   éÿÿÿÿc                 ó|   — | j         sd| _         |                      d¦  «         | j                             |¦  «        S )NTs   HTTP/1.1 100 Continue

)r?   r>   r=   Úread)r6   Úamts     r   rC   zcontinuereader.read„   s:   € ØŒ~ð 	:Ø!ˆDŒNØ�KŠKÐ8Ñ9Ô9Ð9ØŒv�{Š{˜3ÑÔÐr   c                 óB   — |dv rt          | j        |¦  «        S t          ‚)N)s   closes   readlines	   readliness   __iter__)r   r=   ÚAttributeError)r6   Úattrs     r   Ú__getattr__zcontinuereader.__getattr__Š   s&   € ØÐEÐEÐEÝ˜4œ6 4Ñ(Ô(Ð(ÝÐr   N)rA   )r7   r8   r9   Ú__doc__r1   rC   rH   r   r   r   r;   r;   v   sP   € € € € € ðð ðð ð ð
 ð  ð  ð  ðð ð ð ð r   r;   c                 ó€   — t           j        j        }t          j        |                     | d¦  «        d         ¦  «        S )N)ÚErrorzUnknown errorr   )Ú
httpserverÚbasehttprequesthandlerÚ	responsesr   ÚbytesurlÚget)r3   rN   s     r   r/   r/   �   s2   € ÝÔ1Ô;€IÝÔ˜YŸ]š]¨4Ð1KÑLÔLÈQÔOÑPÔPÐPr   c                 ó.   — d| |pt          | ¦  «        fz  S )Ns   %d %s)r/   )r3   r5   s     r   ÚstatusmessagerR   •   s   € Ø�t˜WÐ<­°tÑ(<Ô(<Ð=Ñ=Ð=r   c                 óÐ   — t           j                             | |¦  «        }t           j                             |¦  «        rt          j        |¦  «        S t          j        | ¦  «        S )z%stat fn if it exists, spath otherwise)ÚosÚpathÚjoinÚexistsÚstat)ÚspathÚfnÚcl_paths      r   Úget_statr\   ™   sK   € åŒg�lŠl˜5 "Ñ%Ô%€GÝ	„w‡~‚~�gÑÔð ÝŒw�wÑÔÐåŒw�u‰~Œ~Ðr   c                 óB   — t          | d¦  «        t          j                 S )Ns   00changelog.i)r\   rX   ÚST_MTIME)rY   s    r   Ú	get_mtimer_   ¢   s   € Ý�EÐ+Ñ,Ô,­T¬]Ô;Ð;r   c                 óÆ   — |                       d¦  «        }|D ]H}|dt          j        t          j        fv s(t          j        |v st          j        �t          j        |v r dS ŒIdS )z9Determine if a path is safe to use for filesystem access.ó   /r   NFT)Úsplitr   ÚoscurdirÚospardirÚossepÚosaltsep)rU   ÚpartsÚparts      r   Ú
ispathsaferi   ¦   sk   € à�JŠJ�tÑÔ€EØð ð ˆà�S�(Ô+­XÔ->Ð?Ð?Ð?ÝŒ~ Ð%Ð%ÝÔ Ð,ÝÔ! TÐ)Ð)à�5�5øàˆ4r   c                 ó’  — t          |¦  «        sdS |s7| pt          j        ¦   «         }|� t          j                             |d¦  «        }t          j        j        |                     d¦  «        Ž }t          j        t          j
        t          j        |¦  «        ¦  «        d         pd¦  «        }t          j                             ||¦  «        }	 t          j        |¦  «         t          |d¦  «        5 }|                     ¦   «         }	ddd¦  «         n# 1 swxY w Y   n…# t          $ r t!          t"          d¦  «        ‚t$          $ rZ}
|
j        t&          j        k    rt!          t*          ¦  «        ‚t!          t"          t-          j        |
j        ¦  «        ¦  «        ‚d}
~
ww xY w||j        d<   |                     |	¦  «         |S )	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   staticra   r   z
text/plains   rbs   illegal filenames   Content-Type)ri   r   ÚtemplatedirrT   rU   rV   rb   r   ÚsysbytesÚ	mimetypesÚ
guess_typeÚfsdecoderX   r   rC   Ú	TypeErrorr   ÚHTTP_SERVER_ERRORÚOSErrorÚerrnoÚENOENTÚHTTP_NOT_FOUNDr   Ú
strtolocalÚstrerrorr4   Úsetbodybytes)ÚtemplatepathÚ	directoryÚfnameÚresÚtpÚfpathÚctrU   ÚfhÚdataÚerrs              r   Ú
staticfilerƒ   µ   sä  € õ �eÑÔð Øˆàð 4ØÐ4�YÔ2Ñ4Ô4ˆØˆ>ÝœŸš R¨Ñ3Ô3ˆIåŒGŒL˜%Ÿ+š+ dÑ+Ô+Ð,€EÝ	Ô	ÝÔ�XÔ.¨uÑ5Ô5Ñ6Ô6°qÔ9ÐJ¸]ñ
ô 
€Bõ Œ7�<Š<˜	 5Ñ)Ô)€DðÝ
Œ�‰ŒˆÝ�$˜ÑÔð 	 "Ø—7’7‘9”9ˆDð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	øøåð Dð Dð DÝÕ-Ð/BÑCÔCÐCÝð ð ð ØŒ9�œÒ$Ð$Ý¥Ñ/Ô/Ð/åÝ!¥8Ô#6°s´|Ñ#DÔ#Dñô ð øøøøð	øøøð $&€C„K�Ñ Ø×Ò�TÑÔÐØ€Js=   Ã$D# Ã6DÄD# ÄDÄD# ÄDÄD# Ä#(F%ÅAF Æ F%c              #   ór   K  — | r|r| |z   | z  }| |z   | z  dz  }nd}d}	 |V — |dz  }| r|| k    rd|z
  }d}Œ)z5count parity of horizontal stripes for easier readingé   r   r   )ÚstripecountÚoffsetÚcountÚparitys       r   Ú	paritygenrŠ   Þ   s€   è è € àð �vð à˜vÑ%¨Ñ4ˆØ Ñ&¨;Ñ6¸Ñ:ˆˆàˆØˆðØˆˆˆØ�‰
ˆØð 	˜5 KÒ/Ð/Ø˜‘ZˆFØˆEðr   c                 ót   —  | dd¦  «        p, | dd¦  «        p t           j                             d¦  «        pdS )z¾Return 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   ÚenvironrP   )Úconfigs    r   Úget_contactrŽ   ï   sO   € ð 	ˆˆv�zÑ"Ô"ð 	Øˆ6�%˜Ñ%Ô%ð	åÔ×Ò Ñ)Ô)ð	ð ð	r   c                 óú   — ddl }|                      ddd¬¦  «        }d}|rXd|v rTt          j        |                     ¦   «         j        ¦  «                             d¦  «        }|                     d|¦  «        }||fS )	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›   ý   sƒ   € ð. €K€K€Kð �)Š)�F˜F¨eˆ)Ñ
4Ô
4€CØ€Eà
ð -ˆz˜SÐ Ð ÝÔ(¨¯ª©¬Ô);Ñ<Ô<×CÒCÀDÑIÔIˆØ�kŠk˜* eÑ,Ô,ˆà�ˆ:Ðr   r.   )r   )'r“   rs   rm   rT   rX   r   r   r   Ú r   r   r	   rL   ÚHTTP_OKÚHTTP_CREATEDÚHTTP_NOT_MODIFIEDÚHTTP_BAD_REQUESTr   r!   ru   r   ÚHTTP_NOT_ACCEPTABLEÚHTTP_UNSUPPORTED_MEDIA_TYPErq   r   r+   Ú	permhooksr0   r   r;   r/   rR   r\   r_   ri   rƒ   rŠ   rŽ   r›   r   r   r   ú<module>r¤      sþ  ðð €€€Ø €€€Ø Ð Ð Ð Ø 	€	€	€	Ø €€€ðð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð Œ_€
à
€Ø€ØÐ ØÐ ØÐ Ø€Ø€ØÐ ØÐ Ø!Ð ØÐ ð6ð 6ð 6ð)Gð )Gð )Gðf ˆL€	ð	ð 	ð 	ð 	ð 	�Iñ 	ô 	ð 	ðð ð ð ð ñ ô ð ð4Qð Qð Qð
>ð >ð >ð >ðð ð ð<ð <ð <ðð ð ð&ð &ð &ðRð ð ð ð"ð ð ð"ð "ð "ð "ð "r   