Your IP : 3.145.88.104


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/cgi.cpython-39.opt-2.pyc

a

R�f���@sRdZddlmZmZmZddlmZddlZddlZddl	Z
ddlmZddl
mZddlZddlZddlZgd�Zdadad	d
�Zdd�Zd
d�Zdd�Zeadadejdddfdd�Zd1dd�Zdd�Zdd�ZGdd�d�Z Gdd�d�Z!ejfd d!�Z"d2d"d#�Z#ejfd$d%�Z$d&d'�Z%d(d)�Z&d*d+�Z'd,d-�Z(d.d/�Z)e*d0k�rNe"�dS)3z2.6�)�StringIO�BytesIO�
TextIOWrapper)�MappingN)�
FeedParser)�Message)�MiniFieldStorage�FieldStorage�parse�parse_multipart�parse_header�test�print_exception�
print_environ�
print_form�print_directory�print_arguments�print_environ_usage�cGsDtr*ts*zttd�aWnty(Yn0ts4tantat|�dS)N�a)�logfile�logfp�open�OSError�nolog�log�dolog�Zallargs�r�(/opt/alt/python39/lib64/python3.9/cgi.py�initlog8sr cGst�||d�dS)N�
)r�write)Zfmt�argsrrrr[srcGsdS�Nrrrrrr_srcCsdatrt��datadS)Nr)rr�closer rrrrr�closelogcs
r&�&c
Cs^|durtj}t|d�r |j}nd}t|t�r4|j}d|vrDd|d<|ddk�rt|d�\}}|dkrxt|||d�S|d	kr�t	|d
�}t
r�|t
kr�td��|�|��
|�}	nd}	d
|vr�|	r�|	d}	|	|d
}	n*tjdd��r|	r�|	d}	|	tjd}	|	|d
<n<d
|v�r |d
}	n(tjdd��r<tjd}	nd}	|	|d
<tjj|	||||d�S)N�encodingzlatin-1�REQUEST_METHOD�GET�POST�CONTENT_TYPEzmultipart/form-data)�	separator�!application/x-www-form-urlencoded�CONTENT_LENGTH�Maximum content length exceededr�QUERY_STRINGr'�)r(r-)�sys�stdin�hasattrr(�
isinstancer�bufferrr�int�maxlen�
ValueError�read�decode�argv�urllibr
Zparse_qs)
�fp�environ�keep_blank_values�strict_parsingr-r(�ctype�pdictZclength�qsrrrr
vsF




�r
�utf-8�replacecsv|d�d�}d�|�}t�}|�|�z|d|d<WntyJYn0t||||ddi|d���fd	d
��D�S)N�boundary�asciiz multipart/form-data; boundary={}zCONTENT-LENGTHzContent-Lengthr)r+)�headersr(�errorsr@r-csi|]}|��|��qSr)�getlist)�.0�k�Zfsrr�
<dictcomp>��z#parse_multipart.<locals>.<dictcomp>)r<�formatrZset_type�KeyErrorr	)r?rDr(rKr-rHrCrJrrOrr�s


�rccs�|dd�dkr�|dd�}|�d�}|dkr`|�dd|�|�dd|�dr`|�d|d�}q&|dkrpt|�}|d|�}|��V||d�}qdS)Nr2�;r�"�\"�)�find�count�len�strip)�s�end�frrr�_parseparam�s
(
r_cCs�td|�}|��}i}|D]�}|�d�}|dkr|d|�����}||dd���}t|�dkr�|d|dkr�dkr�nn |dd�}|�dd	��d
d�}|||<q||fS)NrT�=rr2rW���rUz\\�\rV)r_�__next__rXr[�lowerrZrG)�line�parts�keyrD�p�i�name�valuerrrr�s
,
rc@s<eZdZdZdZdZdZiZdZiZ	iZ
dd�Zdd�ZdS)rNcCs||_||_dSr$�rjrk��selfrjrkrrr�__init__	szMiniFieldStorage.__init__cCsd|j|jfS)NzMiniFieldStorage(%r, %r)rl�rnrrr�__repr__szMiniFieldStorage.__repr__)
�__name__�
__module__�__qualname__�filename�list�type�file�type_options�disposition�disposition_optionsrJrorqrrrrr�src@s�eZdZdddejdddddddfdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zd:dd�Z
d;dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdZd'd(�Zd)d*�Zd+Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�ZdS)<r	NrQrrFrGr'cCsXd}||_||_|
|_||_d|vr0|d��}d|_|dksF|dkr�d|vrX|d}
ntjdd�rrtjd}
nd}
|
�t	�
�d�}
t|
�}|dur�dd	i}|dur�i}|d
kr�d	|d<d|vr�|d|d<d|vr�|d|_d|vr�|d|d
<nt|t
tf��std��||_|du�r*tjj|_n<t|t��r@|j|_n&t|d��rXt|d��s`td��||_||_|	|_t|t��s�tdt|�j��||_d|_||_di}}d|jv�r�t|jd�\}}||_||_ d|_!d|v�r�|d|_!d|_"d|v�r
|d|_"|j"du|_#d|jv�r6t|jd�\}}n(|j�sH|d
k�rTdi}}n
d	i}}||_||_$d|v�r�|d�|j|j�|_%nd|_%d}d
|jv�r�zt&|jd
�}Wnt'�y�Yn0t(�r�|t(k�r�t'd��||_)|jdu�r|dk�r||_d|_*|_+d|_,|d	k�r*|�-�n*|dd�dk�rL|�.|||�n|�/�dS)Nr*r)ZHEADr1r2r�surrogateescapezcontent-typer.r+r,r/�content-lengthz?headers must be mapping or an instance of email.message.Messager;�readlinezfp must be file pointerz#outerboundary must be bytes, not %srzcontent-dispositionrjruz
text/plainrHrQrar0�
z
multipart/)0rArB�max_num_fieldsr-�upper�
qs_on_postr3r=�encode�localeZgetpreferredencodingrr6rr�	TypeErrorrJr4r7r?rr5r(rK�bytesrwrr�
outerboundary�
bytes_read�limitrrzr{rjru�_binary_filery�
innerboundaryr8r:r9�lengthrvrx�done�read_urlencoded�
read_multi�read_single)rnr?rJr�r@rArBr�r(rKr�r-�methodrEZcdisprDrCZclenrrrro?s�/
�


�






�

zFieldStorage.__init__cCs&z|j��Wnty Yn0dSr$)rxr%�AttributeErrorrprrr�__del__�szFieldStorage.__del__cCs|Sr$rrprrr�	__enter__�szFieldStorage.__enter__cGs|j��dSr$)rxr%)rnr#rrr�__exit__�szFieldStorage.__exit__cCsd|j|j|jfS)NzFieldStorage(%r, %r, %r))rjrurkrprrrrq�s�zFieldStorage.__repr__cCst|���Sr$)�iter�keysrprrr�__iter__�szFieldStorage.__iter__cCsT|dkrt|��|jr:|j�d�|j��}|j�d�n|jdurL|j}nd}|S)Nrkr)r�rx�seekr;rvrmrrr�__getattr__�s

zFieldStorage.__getattr__cCs^|jdurtd��g}|jD]}|j|kr|�|�q|sBt|��t|�dkrV|dS|SdS)N�
not indexabler2r)rvr�rj�appendrSrZ)rnrg�found�itemrrr�__getitem__s

zFieldStorage.__getitem__cCs8||vr0||}t|t�r(dd�|D�S|jSn|SdS)NcSsg|]
}|j�qSr�rk�rM�xrrr�
<listcomp>rQz)FieldStorage.getvalue.<locals>.<listcomp>�r6rvrk�rnrg�defaultrkrrr�getvalues
zFieldStorage.getvaluecCs4||vr,||}t|t�r$|djS|jSn|SdS�Nrr�r�rrr�getfirsts

zFieldStorage.getfirstcCs:||vr2||}t|t�r(dd�|D�S|jgSngSdS)NcSsg|]
}|j�qSrr�r�rrrr�.rQz(FieldStorage.getlist.<locals>.<listcomp>r�)rnrgrkrrrrL)s

zFieldStorage.getlistcCs*|jdurtd��ttdd�|jD���S)Nr�css|]}|jVqdSr$�rj�rMr�rrr�	<genexpr>8rQz$FieldStorage.keys.<locals>.<genexpr>)rvr��setrprrrr�4s
zFieldStorage.keyscs*|jdurtd��t�fdd�|jD��S)Nr�c3s|]}|j�kVqdSr$r�r��rgrrr�>rQz,FieldStorage.__contains__.<locals>.<genexpr>)rvr��any)rnrgrr�r�__contains__:s
zFieldStorage.__contains__cCst|���Sr$)rZr�rprrr�__len__@szFieldStorage.__len__cCs|jdurtd��t|j�S)NzCannot be converted to bool.)rvr��boolrprrr�__bool__Ds
zFieldStorage.__bool__c	Cs�|j�|j�}t|t�s0td|jt|�jf��|�|j	|j
�}|jrT|d|j7}tj
j||j|j|j	|j
|j|jd�}dd�|D�|_|��dS)N�%s should return bytes, got %sr'�r(rKr�r-cSsg|]\}}t||��qSr�r�rMrgrkrrrr�VrQz0FieldStorage.read_urlencoded.<locals>.<listcomp>)r?r;r�r6r�r:rwrrr<r(rKr�r>r
�	parse_qslrArBr�r-rv�
skip_lines)rnrE�queryrrrr�Is
�
�zFieldStorage.read_urlencodedcCsL|j}t|�std|f��g|_|jrftjj|j|j|j	|j
|j|j|j
d�}|j�dd�|D��|jpp|j}|j��}t|t�s�td|jt|�jf��|jt|�7_|��d|jkr�|r�|j��}|jt|�7_q�|j}|du�r|t|j�8}t�}	d}
|j��}|
|7}
|���s�q0�q|
�s:�q@|jt|
�7_|	�|
�|j
|j��|	��}d|v�rz|d=|jdu�r�dn
|j|j}
||j||||||
|j
|j||j
�}|du�r�|d	8}|j�r�|t|j�8}|d
k�r�td��|j|j7_|j�|�|j �s@|j|j!k�r4d
k�rnn�q@�q|�"�dS)Nz&Invalid boundary in multipart form: %rr�css|]\}}t||�VqdSr$r�r�rrrr�frQz*FieldStorage.read_multi.<locals>.<genexpr>r��--rQr}r2rzMax number of fields exceeded)#r��valid_boundaryr:rvr�r>r
r�rArBr(rKr�r-�extend�FieldStorageClass�	__class__r?r~r6r�rwrrr�rZr[rZfeedr<r%r�r�r�r�r�)rnr@rArBZibr��klassZ
first_liner��parserZhdr_text�datarJr��partrrrr�[sr�

��





��

(zFieldStorage.read_multicCs4|jdkr|��|��n|��|j�d�dSr�)r��read_binaryr��
read_linesrxr�rprrrr��s


zFieldStorage.read_singlei cCs�|��|_|j}|dkr�|dkr�|j�t||j��}t|t�sVt	d|jt
|�jf��|jt
|�7_|std|_q�|j�|�|t
|�}qdS)Nrr�ra)�	make_filerxr�r?r;�min�bufsizer6r�r:rwrrr�rZr�r")rnZtodor�rrrr��s

�zFieldStorage.read_binarycCs@|jrt�|_|_nt�|_|_|jr4|��n|��dSr$)r�rrx�_FieldStorage__filerr��read_lines_to_outerboundary�read_lines_to_eofrprrrr��s
zFieldStorage.read_linescCsv|jdurF|j��t|�dkrF|��|_|j��}|j�|�d|_|jrZ|j�|�n|j�|�|j	|j
��dS)Ni�)r��tellrZr�rxr�r"r�r<r(rK)rnrer�rrrZ__write�s


zFieldStorage.__writecCs:|j�d�}|jt|�7_|s*d|_q6|�|�qdS)N�ra)r?r~r�rZr��_FieldStorage__write)rnrerrrr��szFieldStorage.read_lines_to_eofc	CsJd|j}|d}d}d}d}|jdurFd|jkr>|krFnn�qF|j�d�}|jt|�7_|t|�7}|s~d|_�qF|dkr�||}d}|�d�r�|r�|��}||kr��qF||kr�d|_�qF|}|�	d	�r�d	}|dd
�}d}nL|�	d��rd}|dd�}d}n*|�	d��r.d}|dd�}d}nd}d}|�
||�qdS)
Nr�rQTrr�ra�
r2s
����
F)r�r�r?r~r�rZr��
startswith�rstrip�endswithr�)	rn�
next_boundary�
last_boundaryZdelim�last_line_lfendZ_readre�strippedlineZodelimrrrr��sN
$
z(FieldStorage.read_lines_to_outerboundarycCs�|jr|jrdSd|j}|d}d}|j�d�}|jt|�7_|sPd|_q�|�d�r�|r�|��}||krpq�||kr�d|_q�|�d�}q&dS)Nr�Tr�rar2r�)r�r�r?r~r�rZr�r[)rnr�r�r�rer�rrrr�s$
zFieldStorage.skip_linescCs&|jrt�d�Stjd|jdd�SdS)Nzwb+zw+r!)r(�newline)r��tempfileZ
TemporaryFiler(rprrrr�(s

�zFieldStorage.make_file)N)N) rrrsrt�osr@ror�r�r�rqr�r�r�r�r�rLr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr	s@+�
&


E	
2r	cCs�td�t�tjt_zNt�}t�t�t|�t|�t	�dd�}|fdd�}td�|�Wnt
�Yn0td�daz&t�}t�t�t|�t|�Wnt
�Yn0dS)	NzContent-type: text/htmlcSstd�dS)Nz,testing print_exception() -- <I>italics?</I>)�execrrrrr^[sztest.<locals>.fcSs
|�dSr$r)r^rrr�g]sztest.<locals>.gz9<H3>What follows is a test, not an actual exception:</H3>z*<H1>Second try with a small maxlen...</H1>�2)�printr3�stdout�stderrr	rrrrrrr9)r@�formr^r�rrrr
Js4
r
c	Csx|durt��\}}}ddl}t�td�|�||�|�||�}tdt�d�|dd���t�|d�f�~dS)Nrz+<H3>Traceback (most recent call last):</H3>z<PRE>%s<B>%s</B></PRE>rra)	r3�exc_info�	tracebackr��	format_tb�format_exception_only�html�escape�join)rwrk�tbr�r�rvrrrrqs

��rc	Cs\t|���}t�td�td�|D]"}tdt�|�dt�||��q&td�t�dS)Nz<H3>Shell Environment:</H3>�<DL>�<DT>�<DD>�</DL>)�sortedr�r�r�r�)r@r�rgrrrrs rcCs�t|���}t�td�|s&td�td�|D]Z}tdt�|�ddd�||}tdt�tt|���d	�td
t�t|���q2td�t�dS)Nz<H3>Form Contents:</H3>z<P>No form fields.r�r��:� )r]z<i>z</i>r�r�)r�r�r�r�r��reprrw)r�r�rgrkrrrr�src
Cslt�td�zt��}Wn8tyR}z tdt�t|���WYd}~nd}~00tt�|��t�dS)Nz#<H3>Current Working Directory:</H3>zOSError:)r�r��getcwdrr�r��str)�pwd�msgrrrr�s*rcCs(t�td�t�ttj�t�dS)Nz <H3>Command Line Arguments:</H3>)r�r3r=rrrrr�s

rcCstd�dS)Na�
<H3>These environment variables could have been set:</H3>
<UL>
<LI>AUTH_TYPE
<LI>CONTENT_LENGTH
<LI>CONTENT_TYPE
<LI>DATE_GMT
<LI>DATE_LOCAL
<LI>DOCUMENT_NAME
<LI>DOCUMENT_ROOT
<LI>DOCUMENT_URI
<LI>GATEWAY_INTERFACE
<LI>LAST_MODIFIED
<LI>PATH
<LI>PATH_INFO
<LI>PATH_TRANSLATED
<LI>QUERY_STRING
<LI>REMOTE_ADDR
<LI>REMOTE_HOST
<LI>REMOTE_IDENT
<LI>REMOTE_USER
<LI>REQUEST_METHOD
<LI>SCRIPT_NAME
<LI>SERVER_NAME
<LI>SERVER_PORT
<LI>SERVER_PROTOCOL
<LI>SERVER_ROOT
<LI>SERVER_SOFTWARE
</UL>
In addition, HTTP headers sent by the server may be passed in the
environment as well.  Here are some common variable names:
<UL>
<LI>HTTP_ACCEPT
<LI>HTTP_CONNECTION
<LI>HTTP_HOST
<LI>HTTP_PRAGMA
<LI>HTTP_REFERER
<LI>HTTP_USER_AGENT
</UL>
)r�rrrrr�srcCs(ddl}t|t�rd}nd}|�||�S)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)�rer6r��match)r\r�Z_vb_patternrrrr��s

r��__main__)rFrGr')NNNN)+�__version__�iorrr�collections.abcrr3r�Zurllib.parser>Zemail.parserrZ
email.messagerr�r�r��__all__rrr rrr&rr9r@r
rr_rrr	r
rrrrrrr�rrrrrr�<module>sR#	�
F
:'
/


?>