ok

Mini Shell

Direktori : /proc/self/root/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.6/__pycache__/cgi.cpython-36.opt-2.pyc

3


 \���@s�dZddlmZmZmZddlmZddlZddlZddl	Z
ddlmZddl
mZddlmZddlZddlZddlZdd	d
ddd
dddddddddgZdadadd�Zdd�Zdd�Zdd�Zeadadejddfd d
�Zd4d!d�Zd5d"d�Z d#d
�Z!d$d%�Z"d&d�Z#Gd'd�d�Z$Gd(d	�d	�Z%ejfd)d�Z&d6d*d�Z'ejfd+d�Z(d,d�Z)d-d�Z*d.d�Z+d/d�Z,d7d0d�Z-d1d2�Z.e/d3k�r�e&�dS)8z2.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�cGsHtr.tr.yttd�aWntk
r,YnXts8tantat|�dS)N�a)�logfile�logfp�open�OSError�nolog�log�dolog)�allargs�r"�/usr/lib64/python3.6/cgi.py�initlog:s
r$cGstj||d�dS)N�
)r�write)Zfmt�argsr"r"r#r ]sr cGsdS)Nr")r!r"r"r#rasrcCsdatrtj�datadS)Nr)rr�closer$rr"r"r"r#�closeloges
r)c	CsX|dkrtj}t|d�r |j}nd}t|t�r4|j}d|krDd|d<|ddk�rt|d�\}}|dkrtt||�S|dkr�t	|d	�}t
r�|t
kr�td
��|j|�j
|�}nd}d|kr�|r�|d
}||d}n*tjdd��r�|r�|d
}|tjd}||d<n<d|k�r|d}n(tjdd��r8tjd}nd}||d<tjj||||d�S)N�encodingzlatin-1�REQUEST_METHOD�GET�POST�CONTENT_TYPEzmultipart/form-dataz!application/x-www-form-urlencoded�CONTENT_LENGTHzMaximum content length exceededr�QUERY_STRING�&�)r*)�sys�stdin�hasattrr*�
isinstancer�bufferrr�int�maxlen�
ValueError�read�decode�argv�urllibrr)	�fp�environ�keep_blank_values�strict_parsingr*�ctype�pdict�clength�qsr"r"r#rxsH





cCstdtd�tjj|||�S)Nz=cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead�)r�DeprecationWarningr>rr)rFrArBr"r"r#r�scCstdtd�tjj|||�S)Nz?cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl insteadrG)rrHr>rr
)rFrArBr"r"r#r
�scCs�ddl}d}d|kr|d}t|�s2td|f��d|}d|d}i}d}�x�||k�r�d}d}	|r�|jj|�}
|
jd�}|r�yt|�}Wntk
r�YnX|dkr�tr�|tkr�td��|j|�}	nd}	g}xD|j	�}
|
s�|}P|
j
d��r|
j�}|||fk�rP|j|
�q�W|	dk�r&qR|dk�r�|�r�|d}
|
dd�d
k�r^|
dd�}
n|
dd�dk�r||
dd�}
|
|d<dj
|�}	|
d}
|
�s�qRt|
�\}}|d
k�r�qRd|krR|d}nqR||k�r�||j|	�qR|	g||<qRW|S)Nr��boundaryz&Invalid boundary in multipart form: %rs--r2zcontent-lengthzMaximum content length exceededrGs
�
zcontent-dispositionz	form-data�name���rM���rNrMrMrM)Zhttp.client�valid_boundaryr:ZclientZ
parse_headers�getr8r9r;�readline�
startswith�rstrip�append�joinr)r?rDZhttprJZnextpartZlastpartZpartdict�
terminator�bytes�data�headersrE�lines�line�keyZparamsrLr"r"r#r�s|







ccs�x�|dd�dkr�|dd�}|jd�}x<|dkrd|jdd|�|jdd|�drd|jd|d�}q*W|dkrvt|�}|d|�}|j�V||d�}qWdS)Nr2�;r�"z\"rG)�find�count�len�strip)�s�end�fr"r"r#�_parseparam-s
*
rfcCs�td|�}|j�}i}x�|D]�}|jd�}|dkr|d|�j�j�}||dd�j�}t|�dkr�|d|d
ko�dknr�|dd�}|jdd�jd	d�}|||<qW||fS)Nr]�=rr2rGr^z\\�\z\"rMrM)rf�__next__r_rb�lowerra�replace)r[�partsr\rD�p�irL�valuer"r"r#r9s

,c@s<eZdZdZdZdZdZiZdZiZ	iZ
dd�Zdd�ZdS)r	NcCs||_||_dS)N)rLro)�selfrLror"r"r#�__init___szMiniFieldStorage.__init__cCsd|j|jfS)NzMiniFieldStorage(%r, %r))rLro)rpr"r"r#�__repr__eszMiniFieldStorage.__repr__)
�__name__�
__module__�__qualname__�filename�list�type�file�type_options�disposition�disposition_optionsrYrqrrr"r"r"r#r	Qsc
@s�eZdZdddejddddddf
dd�Zdd	�Zd
d�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
NrIrzutf-8rkcCsLd}||_||_|
|_d|kr*|dj�}d|_|dks@|dkr�d|krR|d}ntjdd�rltjd}nd}|jtj	�d�}t
|�}|dkr�dd	i}|dkr�i}|d
kr�d	|d<d|kr�|d|d<d|kr�|d|_d|kr�|d|d
<nt|tt
f��std��||_|dk�r$tjj|_n<t|t��r:|j|_n&t|d��oNt|d��sZtd��||_||_|	|_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�r0t|jd�\}}n(|j�sB|d
k�rNdi}}n
d	i}}||_||_#d|k�r�|dj|j�|_$nd|_$d}d
|jk�r�yt%|jd
�}Wnt&k
�r�YnXt'�r�|t'k�r�t&d��||_(|jdk�r�|�r�||_d|_)|_*d|_+|d	k�r|j,�n*|dd�dk�r@|j-|||�n|j.�dS)Nr,r+ZHEADr0r2r�surrogateescapezcontent-typez!application/x-www-form-urlencodedr-r.r/zcontent-lengthz?headers must be mapping or an instance of email.message.Messager;rQzfp must be file pointerz#outerboundary must be bytes, not %srzcontent-dispositionrLrvz
text/plainrJrIzMaximum content length exceeded�
z
multipart/rM)/rArB�max_num_fields�upper�
qs_on_postr3r=�encode�locale�getpreferredencodingrr6rr�	TypeErrorrYr4r7r?rr5r*�errorsrWrxrs�
outerboundary�
bytes_read�limitrr{r|rLrv�_binary_filerz�
innerboundaryr8r:r9�lengthrwry�done�read_urlencoded�
read_multi�read_single)rpr?rYr�r@rArBr�r*r�r�methodrFZcdisprDrCZclenr"r"r#rq�s�/












zFieldStorage.__init__cCs(y|jj�Wntk
r"YnXdS)N)ryr(�AttributeError)rpr"r"r#�__del__8szFieldStorage.__del__cCs|S)Nr")rpr"r"r#�	__enter__>szFieldStorage.__enter__cGs|jj�dS)N)ryr()rpr'r"r"r#�__exit__AszFieldStorage.__exit__cCsd|j|j|jfS)NzFieldStorage(%r, %r, %r))rLrvro)rpr"r"r#rrDszFieldStorage.__repr__cCst|j��S)N)�iter�keys)rpr"r"r#�__iter__IszFieldStorage.__iter__cCsT|dkrt|��|jr:|jjd�|jj�}|jjd�n|jdk	rL|j}nd}|S)Nror)r�ry�seekr;rw)rprLror"r"r#�__getattr__Ls

zFieldStorage.__getattr__cCsb|jdkrtd��g}x"|jD]}|j|kr|j|�qW|sFt|��t|�dkrZ|dS|SdS)Nz
not indexabler2r)rwr�rLrT�KeyErrorra)rpr\�found�itemr"r"r#�__getitem__Ys

zFieldStorage.__getitem__cCs8||kr0||}t|t�r(dd�|D�S|jSn|SdS)NcSsg|]
}|j�qSr")ro)�.0�xr"r"r#�
<listcomp>lsz)FieldStorage.getvalue.<locals>.<listcomp>)r6rwro)rpr\�defaultror"r"r#�getvaluegs
zFieldStorage.getvaluecCs4||kr,||}t|t�r$|djS|jSn|SdS)Nr)r6rwro)rpr\r�ror"r"r#�getfirstrs

zFieldStorage.getfirstcCs:||kr2||}t|t�r(dd�|D�S|jgSngSdS)NcSsg|]
}|j�qSr")ro)r�r�r"r"r#r��sz(FieldStorage.getlist.<locals>.<listcomp>)r6rwro)rpr\ror"r"r#�getlist}s

zFieldStorage.getlistcCs*|jdkrtd��ttdd�|jD���S)Nz
not indexablecss|]}|jVqdS)N)rL)r�r�r"r"r#�	<genexpr>�sz$FieldStorage.keys.<locals>.<genexpr>)rwr��set)rpr"r"r#r��s
zFieldStorage.keyscs*|jdkrtd��t�fdd�|jD��S)Nz
not indexablec3s|]}|j�kVqdS)N)rL)r�r�)r\r"r#r��sz,FieldStorage.__contains__.<locals>.<genexpr>)rwr��any)rpr\r")r\r#�__contains__�s
zFieldStorage.__contains__cCst|j��S)N)rar�)rpr"r"r#�__len__�szFieldStorage.__len__cCs|jdkrtd��t|j�S)NzCannot be converted to bool.)rwr��bool)rpr"r"r#�__bool__�s
zFieldStorage.__bool__cCs�|jj|j�}t|t�s0td|jt|�jf��|j|j	|j
�}|jrT|d|j7}tj
j||j|j|j	|j
|jd�}dd�|D�|_|j�dS)Nz%s should return bytes, got %sr1)r*r�rcSsg|]\}}t||��qSr")r	)r�r\ror"r"r#r��sz0FieldStorage.read_urlencoded.<locals>.<listcomp>)r?r;r�r6rWr:rxrsr<r*r�r�r>rr
rArBrrw�
skip_lines)rprF�queryr"r"r#r��s


zFieldStorage.read_urlencodedcCs8|j}t|�std|f��g|_|jrbtjj|j|j|j	|j
|j|jd�}|jj
dd�|D��|jpl|j}|jj�}t|t�s�td|jt|�jf��|jt|�7_x6|j�d|jkr�|r�|jj�}|jt|�7_q�W|j}|dk	�r|t|j�8}�x&t�}	d}
x$|jj�}|
|7}
|j��sP�qW|
�s>P|jt|
�7_|	j|
j|j
|j��|	j�}d|k�r~|d=||j||||||j|j|j
|j|�
}
|dk	�r�|d	8}|
j�r�|t|
j�8}|d
k�r�td��|j|
j7_|jj|
�|
j�s$|j|j k�od
kn�rP�qW|j!�dS)Nz&Invalid boundary in multipart form: %r)r*r�rcss|]\}}t||�VqdS)N)r	)r�r\ror"r"r#r��sz*FieldStorage.read_multi.<locals>.<genexpr>z%s should return bytes, got %ss--rIzcontent-lengthr2rzMax number of fields exceeded)"r�rOr:rwr�r>rr
rArBr*r�r�extend�FieldStorageClass�	__class__r?rQr6rWrxrsr�rarbrZfeedr<r(r�rTr�r�r�)rpr@rArBZibr��klassZ
first_liner�parserZhdr_textrXrY�partr"r"r#r��sh









(zFieldStorage.read_multicCs4|jdkr|j�|j�n|j�|jjd�dS)Nr)r��read_binaryr��
read_linesryr�)rpr"r"r#r��s


zFieldStorage.read_single�icCs�|j�|_|j}|dkr�xx|dkr�|jjt||j��}t|t�sXt	d|jt
|�jf��|jt
|�7_|svd|_P|jj|�|t
|�}qWdS)Nrz%s should return bytes, got %sr2rM)�	make_fileryr�r?r;�min�bufsizer6rWr:rxrsr�rar�r&)rpZtodorXr"r"r#r��s


zFieldStorage.read_binarycCs@|jrt�|_|_nt�|_|_|jr4|j�n|j�dS)N)r�rry�_FieldStorage__filerr��read_lines_to_outerboundary�read_lines_to_eof)rpr"r"r#r�s
zFieldStorage.read_linescCsv|jdk	rF|jj�t|�dkrF|j�|_|jj�}|jj|�d|_|jrZ|jj|�n|jj|j|j	|j
��dS)Ni�)r��tellrar�ryr�r&r�r<r*r�)rpr[rXr"r"r#Z__writes


zFieldStorage.__writecCs>x8|jjd�}|jt|�7_|s,d|_P|j|�qWdS)Nr2�irM)r?rQr�rar��_FieldStorage__write)rpr[r"r"r#r�(szFieldStorage.read_lines_to_eofc	Cs,d|j}|d}d}d}d}�x||jkr.P|jjd�}|jt|�7_|t|�7}|sdd
|_P|dkrx||}d}|jd�r�|r�|j�}||kr�P||kr�d|_P|}|j	d�r�d}|dd�}d}nJ|j	d
�r�d
}|dd�}d}n*|j	d��rd}|dd�}d}nd}d}|j
||�q"WdS)Ns--rITrr2r��
s
rGrKFirMrNrMrM)r�r�r?rQr�rar�rRrS�endswithr�)	rp�
next_boundary�
last_boundaryZdelim�last_line_lfendZ_readr[�strippedlineZodelimr"r"r#r�2sP



z(FieldStorage.read_lines_to_outerboundarycCs�|js|jrdSd|j}|d}d}xh|jjd�}|jt|�7_|sTd|_P|jd�r�|r�|j�}||krtP||kr�d|_P|jd�}q*WdS)Ns--Tr2r�rKirM)r�r�r?rQr�rar�rb)rpr�r�r�r[r�r"r"r#r�cs&
zFieldStorage.skip_linescCs&|jrtjd�Stjd|jdd�SdS)Nzwb+zw+r%)r*�newline)r��tempfileZ
TemporaryFiler*)rpr"r"r#r�ys
zFieldStorage.make_file)N)Ni ) rsrtru�osr@rqr�r�r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r"r"r#r
js>+!


C	
1cCs�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#re�sztest.<locals>.fcSs
|�dS)Nr")rer"r"r#�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@�formrer�r"r"r#r�s4
cCsx|dkrtj�\}}}ddl}t�td�|j||�|j||�}tdtjdj|dd���tj|d�f�~dS)Nrz+<H3>Traceback (most recent call last):</H3>z<PRE>%s<B>%s</B></PRE>rr2rMrM)	r3�exc_info�	tracebackr��	format_tb�format_exception_only�htmlrrU)rxro�tbr�r�rwr"r"r#r�s
cCs`t|j��}t�td�td�x*|D]"}tdtj|�dtj||��q(Wtd�t�dS)Nz<H3>Shell Environment:</H3>z<DL>z<DT>z<DD>z</DL>)�sortedr�r�r�r)r@r�r\r"r"r#r�s
"cCs�t|j��}t�td�|s&td�td�xb|D]Z}tdtj|�ddd�||}tdtjtt|���d	�td
tjt|���q4Wtd�t�dS)Nz<H3>Form Contents:</H3>z<P>No form fields.z<DL>z<DT>�:� )rdz<i>z</i>z<DD>z</DL>)r�r�r�r�r�reprrx)r�r�r\ror"r"r#r�s
cCsjt�td�ytj�}Wn6tk
rP}ztdtjt|���WYdd}~XnXttj|��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�r3r=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�|jdd�}|jdd�}|jdd	�}|rB|jd
d�}|S)Nz1cgi.escape is deprecated, use html.escape insteadrG)�
stacklevelr1z&amp;�<z&lt;�>z&gt;r^z&quot;)rrHrk)rcZquoter"r"r#r-s
cCs(ddl}t|t�rd}nd}|j||�S)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)�rer6rW�match)rcr�Z_vb_patternr"r"r#rO9s

rO�__main__)rr)rr)NNNN)N)0�__version__�iorrr�collectionsrr3r�Zurllib.parser>Zemail.parserrZ
email.messager�warningsrr�r�r��__all__rrr$r rr)rr9r@rrr
rrfrr	r
rrrrrrrrrOrsr"r"r"r#�<module>s^#	E

d5'
/



Zerion Mini Shell 1.0