Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/cgi.cpython-37.opt-2.pyc

B

YI~d��@s�dZddlmZmZmZddlmZddlZddlZddl	Z
ddlmZddl
mZddlmZddlZddlZddlZdd	d
ddd
dddddddddgZdadadd�Zdd�Zdd�Zdd�Zeadadejddd fd!d
�Zd7d"d�Zd8d#d�Z d9d&d
�Z!d'd(�Z"d)d�Z#Gd*d�d�Z$Gd+d	�d	�Z%ejfd,d�Z&d:d-d�Z'ejfd.d�Z(d/d�Z)d0d�Z*d1d�Z+d2d�Z,d;d3d�Z-d4d5�Z.e/d6k�r�e&�dS)<z2.6�)�StringIO�BytesIO�
TextIOWrapper)�MappingN)�
FeedParser)�Message)�warn�MiniFieldStorage�FieldStorage�parse�parse_qs�	parse_qsl�parse_multipart�parse_header�test�print_exception�
print_environ�
print_form�print_directory�print_arguments�print_environ_usage�escape�cGsFtr,ts,yttd�aWntk
r*YnXts6tantat|�dS)N�a)�logfile�logfp�open�OSError�nolog�log�dolog)�allargs�r"�(/opt/alt/python37/lib64/python3.7/cgi.py�initlog:sr$cGst�||d�dS)N�
)r�write)Zfmt�argsr"r"r#r ]sr cGsdS)Nr")r!r"r"r#rasrcCsdatrt��datadS)Nr)rr�closer$rr"r"r"r#�closeloges
r)�&c
Cs^|dkrtj}t|d�r |j}nd}t|t�r4|j}d|krDd|d<|ddk�rt|d�\}}|dkrxt|||d�S|d	kr�t	|d
�}t
r�|t
kr�td��|�|��
|�}	nd}	d
|kr�|	r�|	d}	|	|d
}	n*tjdd��r|	r�|	d}	|	tjd}	|	|d
<n<d
|k�r |d
}	n(tjdd��r<tjd}	nd}	|	|d
<tjj|	||||d�S)N�encodingzlatin-1�REQUEST_METHOD�GET�POST�CONTENT_TYPEzmultipart/form-data)�	separatorz!application/x-www-form-urlencoded�CONTENT_LENGTHzMaximum content length exceededr�QUERY_STRINGr*�)r+r0)�sys�stdin�hasattrr+�
isinstancer�bufferrr�int�maxlen�
ValueError�read�decode�argv�urllibrr)
�fp�environ�keep_blank_values�strict_parsingr0r+�ctype�pdictZclength�qsr"r"r#rxsH




cCstdtd�tj�|||�S)Nz=cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead�)r�DeprecationWarningr?rr)rFrBrCr"r"r#r�scCstdtd�tj�|||�S)Nz?cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl insteadrG)rrHr?rr
)rFrBrCr"r"r#r
�s�utf-8�replacecsx|d�d�}d�|�}t�}|�|�y|d|d<Wntk
rLYnXt||||ddi|d���fd	d
��D�S)N�boundary�asciiz multipart/form-data; boundary={}zCONTENT-LENGTHzContent-Lengthr,r.)�headersr+�errorsrAr0csi|]}��|�|�qSr")�getlist)�.0�k)�fsr"r#�
<dictcomp>�sz#parse_multipart.<locals>.<dictcomp>)r=�formatrZset_type�KeyErrorr
)r@rEr+rNr0rKrDrMr")rRr#r�s


ccs�x�|dd�dkr�|dd�}|�d�}x<|dkrd|�dd|�|�dd|�drd|�d|d�}q*W|dkrvt|�}|d|�}|��V||d�}qWdS)Nr3�;r�"z\"rG)�find�count�len�strip)�s�end�fr"r"r#�_parseparam�s
*
r_cCs�td|�}|��}i}x�|D]�}|�d�}|dkr|d|�����}||dd���}t|�dkr�|d|dkr�dkr�nn |dd�}|�dd	��d
d�}|||<qW||fS)NrV�=rr3rG���rWz\\�\z\")r_�__next__rXr[�lowerrZrJ)�line�parts�keyrE�p�i�name�valuer"r"r#r�s

,c@s<eZdZdZdZdZdZiZdZiZ	iZ
dd�Zdd�ZdS)r	NcCs||_||_dS)N)rjrk)�selfrjrkr"r"r#�__init__szMiniFieldStorage.__init__cCsd|j|jfS)NzMiniFieldStorage(%r, %r))rjrk)rlr"r"r#�__repr__ szMiniFieldStorage.__repr__)
�__name__�
__module__�__qualname__�filename�list�type�file�type_options�disposition�disposition_optionsrMrmrnr"r"r"r#r	sc@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
N�rzutf-8rJr*cCsZd}||_||_|
|_||_d|kr0|d��}d|_|dksF|dkr�d|krX|d}
ntjdd�rrtjd}
nd}
|
�t	�
�d�}
t|
�}|dkr�dd	i}|dkr�i}|d
kr�d	|d<d|kr�|d|d<d|kr�|d|_d|kr�|d|d
<nt|t
tf��std��||_|dk�r*tjj|_n<t|t��r@|j|_n&t|d��rXt|d��s`td��||_||_|	|_t|t��s�tdt|�j��||_d|_||_di}}d|jk�r�t|jd�\}}||_||_ d|_!d|k�r�|d|_!d|_"d|k�r
|d|_"|j"dk	|_#d|jk�r6t|jd�\}}n(|j�sH|d
k�rTdi}}n
d	i}}||_||_$d|k�r�|d�|j|j�|_%nd|_%d}d
|jk�r�yt&|jd
�}Wnt'k
�r�YnXt(�r�|t(k�r�t'd��||_)|jdk�r|dk�r||_d|_*|_+d|_,|d	k�r,|�-�n*|dd�dk�rN|�.|||�n|�/�dS)Nr-r,ZHEADr2r3r�surrogateescapezcontent-typez!application/x-www-form-urlencodedr.r/r1zcontent-lengthz?headers must be mapping or an instance of email.message.Messager<�readlinezfp must be file pointerz#outerboundary must be bytes, not %srzcontent-dispositionrjrrz
text/plainrKryrazMaximum content length exceeded�
z
multipart/)0rBrC�max_num_fieldsr0�upper�
qs_on_postr4r>�encode�locale�getpreferredencodingrr7rr�	TypeErrorrMr5r8r@rr6r+rN�bytesrtro�
outerboundary�
bytes_read�limitrrwrxrjrr�_binary_filerv�
innerboundaryr9r;r:�lengthrsru�done�read_urlencoded�
read_multi�read_single)rlr@rMr�rArBrCr�r+rNr}r0�methodrFZcdisprErDZclenr"r"r#rmPs�/












zFieldStorage.__init__cCs(y|j��Wntk
r"YnXdS)N)rur(�AttributeError)rlr"r"r#�__del__�szFieldStorage.__del__cCs|S)Nr")rlr"r"r#�	__enter__�szFieldStorage.__enter__cGs|j��dS)N)rur()rlr'r"r"r#�__exit__�szFieldStorage.__exit__cCsd|j|j|jfS)NzFieldStorage(%r, %r, %r))rjrrrk)rlr"r"r#rnszFieldStorage.__repr__cCst|���S)N)�iter�keys)rlr"r"r#�__iter__szFieldStorage.__iter__cCsT|dkrt|��|jr:|j�d�|j��}|j�d�n|jdk	rL|j}nd}|S)Nrkr)r�ru�seekr<rs)rlrjrkr"r"r#�__getattr__	s

zFieldStorage.__getattr__cCsb|jdkrtd��g}x"|jD]}|j|kr|�|�qW|sFt|��t|�dkrZ|dS|SdS)Nz
not indexabler3r)rsr�rj�appendrUrZ)rlrg�found�itemr"r"r#�__getitem__s

zFieldStorage.__getitem__cCs8||kr0||}t|t�r(dd�|D�S|jSn|SdS)NcSsg|]
}|j�qSr")rk)rP�xr"r"r#�
<listcomp>)sz)FieldStorage.getvalue.<locals>.<listcomp>)r7rsrk)rlrg�defaultrkr"r"r#�getvalue$s
zFieldStorage.getvaluecCs4||kr,||}t|t�r$|djS|jSn|SdS)Nr)r7rsrk)rlrgr�rkr"r"r#�getfirst/s

zFieldStorage.getfirstcCs:||kr2||}t|t�r(dd�|D�S|jgSngSdS)NcSsg|]
}|j�qSr")rk)rPr�r"r"r#r�?sz(FieldStorage.getlist.<locals>.<listcomp>)r7rsrk)rlrgrkr"r"r#rO:s

zFieldStorage.getlistcCs*|jdkrtd��ttdd�|jD���S)Nz
not indexablecss|]}|jVqdS)N)rj)rPr�r"r"r#�	<genexpr>Isz$FieldStorage.keys.<locals>.<genexpr>)rsr��set)rlr"r"r#r�Es
zFieldStorage.keyscs*|jdkrtd��t�fdd�|jD��S)Nz
not indexablec3s|]}|j�kVqdS)N)rj)rPr�)rgr"r#r�Osz,FieldStorage.__contains__.<locals>.<genexpr>)rsr��any)rlrgr")rgr#�__contains__Ks
zFieldStorage.__contains__cCst|���S)N)rZr�)rlr"r"r#�__len__QszFieldStorage.__len__cCs|jdkrtd��t|j�S)NzCannot be converted to bool.)rsr��bool)rlr"r"r#�__bool__Us
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)Nz%s should return bytes, got %sr*)r+rNr}r0cSsg|]\}}t||��qSr")r	)rPrgrkr"r"r#r�gsz0FieldStorage.read_urlencoded.<locals>.<listcomp>)r@r<r�r7r�r;rtror=r+rNrr?rr
rBrCr}r0rs�
skip_lines)rlrF�queryr"r"r#r�Zs

zFieldStorage.read_urlencodedcCsT|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_x6|��d|jkr�|r�|j��}|jt|�7_q�W|j}|dk	�r|t|j�8}�x>t�}	d}
x$|j��}|
|7}
|���sP�qW|
�sBP|jt|
�7_|	�|
�|j
|j��|	��}d|k�r�|d=|jdk�r�dn
|j|j}
||j||||||
|j
|j||j
�}|dk	�r�|d	8}|j�r�|t|j�8}|d
k�r�td��|j|j7_|j�|�|j �s@|j|j!k�r<d
k�r
nnP�q
W|�"�dS)Nz&Invalid boundary in multipart form: %r)r+rNr}r0css|]\}}t||�VqdS)N)r	)rPrgrkr"r"r#r�wsz*FieldStorage.read_multi.<locals>.<genexpr>z%s should return bytes, got %ss--ryzcontent-lengthr3rzMax number of fields exceeded)#r��valid_boundaryr;rsrr?rr
rBrCr+rNr}r0�extend�FieldStorageClass�	__class__r@r{r7r�rtror�rZr[rZfeedr=r(r�r�r�r�r�)rlrArBrCZibr��klassZ
first_liner}�parserZhdr_text�datarMr��partr"r"r#r�lsl








(zFieldStorage.read_multicCs4|jdkr|��|��n|��|j�d�dS)Nr)r��read_binaryr��
read_linesrur�)rlr"r"r#r��s


zFieldStorage.read_singlei cCs�|��|_|j}|dkr�xx|dkr�|j�t||j��}t|t�sXt	d|jt
|�jf��|jt
|�7_|svd|_P|j�|�|t
|�}qWdS)Nrz%s should return bytes, got %sra)�	make_filerur�r@r<�min�bufsizer7r�r;rtror�rZr�r&)rlZtodor�r"r"r#r��s


zFieldStorage.read_binarycCs@|jrt�|_|_nt�|_|_|jr4|��n|��dS)N)r�rru�_FieldStorage__filerr��read_lines_to_outerboundary�read_lines_to_eof)rlr"r"r#r��s
zFieldStorage.read_linescCsv|jdk	rF|j��t|�dkrF|��|_|j��}|j�|�d|_|jrZ|j�|�n|j�|�|j	|j
��dS)Ni�)r��tellrZr�rur�r&r�r=r+rN)rlrer�r"r"r#Z__write�s


zFieldStorage.__writecCs>x8|j�d�}|jt|�7_|s,d|_P|�|�qWdS)Nira)r@r{r�rZr��_FieldStorage__write)rlrer"r"r#r��szFieldStorage.read_lines_to_eofc	CsHd|j}|d}d}d}d}�x"|jdk	rHd|jkrB|krHnnP|j�d�}|jt|�7_|t|�7}|s~d|_P|dkr�||}d}|�d�r�|r�|��}||kr�P||kr�d|_P|}|�	d	�r�d	}|dd
�}d}nL|�	d��rd}|dd�}d}n*|�	d��r*d}|dd�}d}nd}d}|�
||�q"WdS)
Ns--ryTrira�
r3s
����
F)r�r�r@r{r�rZr��
startswith�rstrip�endswithr�)	rl�
next_boundary�
last_boundaryZdelim�last_line_lfendZ_readre�strippedlineZodelimr"r"r#r��sP
$
z(FieldStorage.read_lines_to_outerboundarycCs�|jr|jrdSd|j}|d}d}xh|j�d�}|jt|�7_|sRd|_P|�d�r�|r�|��}||krrP||kr�d|_P|�d�}q(WdS)Ns--Tirar3r�)r�r�r@r{r�rZr�r[)rlr�r�r�rer�r"r"r#r�#s&
zFieldStorage.skip_linescCs&|jrt�d�Stjd|jdd�SdS)Nzwb+zw+r%)r+�newline)r��tempfileZ
TemporaryFiler+)rlr"r"r#r�9s
zFieldStorage.make_file)N)N) rorprq�osrArmr�r�r�rnr�r�r�r�r�rOr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r"r"r#r
%s>+#


E	
2cCs�td�t�tjt_yNt�}t�t�t|�t|�t	�dd�}|fdd�}td�|�Wnt
�YnXtd�day&t�}t�t�t|�t|�Wnt
�YnXdS)	NzContent-type: text/htmlcSstd�dS)Nz,testing print_exception() -- <I>italics?</I>)�execr"r"r"r#r^lsztest.<locals>.fcSs
|�dS)Nr")r^r"r"r#�gnsztest.<locals>.gz9<H3>What follows is a test, not an actual exception:</H3>z*<H1>Second try with a small maxlen...</H1>�2)�printr4�stdout�stderrr
rrrrrrr:)rA�formr^r�r"r"r#r[s4
c	Csx|dkrt��\}}}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)	r4�exc_info�	tracebackr��	format_tb�format_exception_only�htmlr�join)rtrk�tbr�r�rsr"r"r#r�s
c	Cs`t|���}t�td�td�x*|D]"}tdt�|�dt�||��q(Wtd�t�dS)Nz<H3>Shell Environment:</H3>z<DL>z<DT>z<DD>z</DL>)�sortedr�r�r�r)rAr�rgr"r"r#r�s
"cCs�t|���}t�td�|s&td�td�xb|D]Z}tdt�|�ddd�||}tdt�tt|���d	�td
t�t|���q4Wtd�t�dS)Nz<H3>Form Contents:</H3>z<P>No form fields.z<DL>z<DT>�:� )r]z<i>z</i>z<DD>z</DL>)r�r�r�r�r�reprrt)r�r�rgrkr"r"r#r�s
c
Csjt�td�yt��}Wn6tk
rP}ztdt�t|���Wdd}~XYnXtt�|��t�dS)Nz#<H3>Current Working Directory:</H3>zOSError:)r�r��getcwdrr�r�str)�pwd�msgr"r"r#r�s&cCs(t�td�t�ttj�t�dS)Nz <H3>Command Line Arguments:</H3>)r�r4r>r"r"r"r#r�s

cCs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�r"r"r"r#r�s'cCsFtdtdd�|�dd�}|�dd�}|�dd	�}|rB|�d
d�}|S)Nz1cgi.escape is deprecated, use html.escape insteadrG)�
stacklevelr*z&amp;�<z&lt;�>z&gt;rWz&quot;)rrHrJ)r\Zquoter"r"r#r�s
cCs(ddl}t|t�rd}nd}|�||�S)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)�rer7r��match)r\r�Z_vb_patternr"r"r#r��s

r��__main__)rr)rr)rIrJr*)NNNN)N)0�__version__�iorrrZcollections.abcrr4r�Zurllib.parser?Zemail.parserrZ
email.messager�warningsrr�r�r��__all__rrr$r rr)rr:rArrr
rr_rr	r
rrrrrrrrr�ror"r"r"r#�<module>s`#	H


:'
/



Hacked By AnonymousFox1.0, Coded By AnonymousFox