ok

Mini Shell

Direktori : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/cgi.cpython-35.opt-2.pyc



���]�@sIdZddlmZmZmZddlmZddlZddlZddl	Z
ddlmZddl
mZddlmZddlZddlZddlZdd	d
ddd
ddddddddgZdadadd�Zdd�Zdd�Zdd�Zeadadejdddd
�Zddd d�Zddd!d�Z d"d
�Z!d#d$�Z"d%d�Z#Gd&d�d�Z$Gd'd	�d	�Z%ejd(d)�Z&ddddd*d�Z'ejd+d�Z(d,d�Z)d-d�Z*d.d�Z+d/d�Z,dd0d�Z-d1d2�Z.e/d3krEe&�dS)4z2.6�)�StringIO�BytesIO�
TextIOWrapper)�MappingN)�
FeedParser)�Message)�warn�MiniFieldStorage�FieldStorage�parse�parse_qs�	parse_qsl�parse_multipart�parse_header�print_exception�
print_environ�
print_form�print_directory�print_arguments�print_environ_usage�escape�cGsXtr5tr5yttd�aWntk
r4YnXtsDtantat|�dS)N�a)�logfile�logfp�open�OSError�nolog�log�dolog)�allargs�r!�(/opt/alt/python35/lib64/python3.5/cgi.py�initlog:s

	r#cGstj||d�dS)N�
)r�write)�fmt�argsr!r!r"r]srcGsdS)Nr!)r r!r!r"rasrcCs&datrtj�datadS)Nr)rr�closer#rr!r!r!r"�closeloges

r)c	Cs�|dkrtj}t|d�r0|j}nd}t|t�rN|j}d|krdd|d<|ddkrlt|d�\}}|dkr�t||�S|dkr�t	|d	�}t
r�|t
kr�td
��|j|�j
|�}nd}d|kr+|r|d
}||d}n4tjdd�r_|rN|d
}|tjd}||d<nLd|kr�|d}n3tjdd�r�tjd}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�&�)�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		






cCs&tdtd�tjj|||�S)Nz=cgi.parse_qs is deprecated, use urllib.parse.parse_qs instead�)r�DeprecationWarningr>rr)rFrArBr!r!r"r�s
cCs&tdtd�tjj|||�S)Nz?cgi.parse_qsl is deprecated, use urllib.parse.parse_qsl insteadrG)rrHr>rr
)rFrArBr!r!r"r
�s
cCs�ddl}d}d|kr(|d}t|�sGtd|f��d|}d|d}i}d}x!||kr�d}d}	|r|jj|�}
|
jd�}|r�yt|�}Wntk
r�YnX|dkrtr|tkrtd��|j|�}	nd}	g}xX|j	�}
|
s<|}P|
j
d�rj|
j�}|||fkrjP|j|
�q#W|	dkr�qn|dkr|r|d}
|
dd�d
kr�|
dd�}
n&|
dd�dkr�|
dd�}
|
|d<dj
|�}	|
d}
|
s!qnt|
�\}}|d
krBqnd|krn|d}nqn||kr~||j|	�qn|	g||<qnW|S)Nr��boundaryz&Invalid boundary in multipart form: %rs--r2zcontent-lengthzMaximum content length exceededrGs
s
zcontent-dispositionz	form-data�name���rL���rMrLrLrL)Zhttp.client�valid_boundaryr:�clientZ
parse_headers�getr8r9r;�readline�
startswith�rstrip�append�joinr)r?rDZhttprJZnextpartZlastpartZpartdict�
terminator�bytes�data�headersrE�lines�line�key�paramsrKr!r!r"r�s|







ccs�x�|dd�dkr�|dd�}|jd�}xR|dkr�|jdd|�|jdd|�dr�|jd|d�}q;W|dkr�t|�}|d|�}|j�V||d�}qWdS)Nr2�;r�"z\"rG)�find�count�len�strip)�s�end�fr!r!r"�_parseparam-s;rgcCs�td|�}|j�}i}x�|D]�}|jd�}|dkr)|d|�j�j�}||dd�j�}t|�dkr�|d|d
ko�dknr�|dd�}|jdd�jd	d�}|||<q)W||fS)Nr^�=rr2rGr_z\\�\z\"rLrL)rg�__next__r`rc�lowerrb�replace)r[�partsr\rD�p�irK�valuer!r!r"r9s
6c@sXeZdZdZdZdZdZiZdZiZ	iZ
dd�Zdd�ZdS)r	NcCs||_||_dS)N)rKrp)�selfrKrpr!r!r"�__init___s	zMiniFieldStorage.__init__cCsd|j|jfS)NzMiniFieldStorage(%r, %r))rKrp)rqr!r!r"�__repr__eszMiniFieldStorage.__repr__)
�__name__�
__module__�__qualname__�filename�list�type�file�type_options�disposition�disposition_optionsrYrrrsr!r!r!r"r	Qsc@sleZdZdddejddddddd�	Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zddd�Z
ddd�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-8rlc
Cshd}
||_||_d|kr4|dj�}
d|_|
dksU|
dkr�d|krn|d}n)tjdd�r�tjd}nd}|jtj�d�}t	|�}|dkr�dd	i}|dkrKi}|
d
kr�d	|d<d|kr|d|d<d|kr.|d|_d|krl|d|d
<n!t
|ttf�slt
d��||_|dkr�tjj|_nQt
|t�r�|j|_n3t|d�o�t|d�s�t
d��||_||_|	|_t
|t�st
dt|�j��||_d|_||_di}}
d|jkrnt|jd�\}}
||_|
|_d|_d|
kr�|
d|_d|_ d|
kr�|
d|_ |j dk	|_!d|jkrt|jd�\}}
n2|js|
d
kr&di}}
n
d	i}}
||_|
|_"d|
krm|
dj|j�|_#n	d|_#d}d
|jkr�yt$|jd
�}Wnt%k
r�YnXt&r�|t&kr�t%d��||_'|jdkr�|r�||_d|_(|_)d|_*|d	kr.|j+�n6|dd�dkrZ|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-dispositionrKrwz
text/plainrJrIzMaximum content length exceeded�
z
multipart/rL).rArB�upper�
qs_on_postr3r=�encode�locale�getpreferredencodingrr6rr�	TypeErrorrYr4r7r?rr5r*�errorsrWryrt�
outerboundary�
bytes_read�limitrr|r}rKrw�_binary_filer{�
innerboundaryr8r:r9�lengthrxrz�done�read_urlencoded�
read_multi�read_single)rqr?rYr�r@rArBr�r*r��methodrFZcdisprDrCZclenr!r!r"rr�s�+			
	

							
			
	

			
			
zFieldStorage.__init__cCs*y|jj�Wntk
r%YnXdS)N)rzr(�AttributeError)rqr!r!r"�__del__3s
zFieldStorage.__del__cCs|S)Nr!)rqr!r!r"�	__enter__9szFieldStorage.__enter__cGs|jj�dS)N)rzr()rqr'r!r!r"�__exit__<szFieldStorage.__exit__cCsd|j|j|jfS)NzFieldStorage(%r, %r, %r))rKrwrp)rqr!r!r"rs?szFieldStorage.__repr__cCst|j��S)N)�iter�keys)rqr!r!r"�__iter__DszFieldStorage.__iter__cCsx|dkrt|��|jrS|jjd�|jj�}|jjd�n!|jdk	rn|j}nd}|S)Nrpr)r�rz�seekr;rx)rqrKrpr!r!r"�__getattr__Gs	zFieldStorage.__getattr__cCs�|jdkrtd��g}x-|jD]"}|j|kr+|j|�q+W|sct|��t|�dkr}|dS|SdS)Nz
not indexabler2r)rxr�rKrT�KeyErrorrb)rqr\�found�itemr!r!r"�__getitem__TszFieldStorage.__getitem__cCsH||kr@||}t|t�r6dd�|D�S|jSn|SdS)NcSsg|]}|j�qSr!)rp)�.0�xr!r!r"�
<listcomp>gs	z)FieldStorage.getvalue.<locals>.<listcomp>)r6rxrp)rqr\�defaultrpr!r!r"�getvaluebs

zFieldStorage.getvaluecCsB||kr:||}t|t�r0|djS|jSn|SdS)Nr)r6rxrp)rqr\r�rpr!r!r"�getfirstms

zFieldStorage.getfirstcCsK||krC||}t|t�r6dd�|D�S|jgSngSdS)NcSsg|]}|j�qSr!)rp)r�r�r!r!r"r�}s	z(FieldStorage.getlist.<locals>.<listcomp>)r6rxrp)rqr\rpr!r!r"�getlistxs

zFieldStorage.getlistcCs;|jdkrtd��ttdd�|jD���S)Nz
not indexablecss|]}|jVqdS)N)rK)r�r�r!r!r"�	<genexpr>�sz$FieldStorage.keys.<locals>.<genexpr>)rxr��set)rqr!r!r"r��szFieldStorage.keyscs;|jdkrtd��t�fdd�|jD��S)Nz
not indexablec3s|]}|j�kVqdS)N)rK)r�r�)r\r!r"r��sz,FieldStorage.__contains__.<locals>.<genexpr>)rxr��any)rqr\r!)r\r"�__contains__�szFieldStorage.__contains__cCst|j��S)N)rbr�)rqr!r!r"�__len__�szFieldStorage.__len__cCs(|jdkrtd��t|j�S)NzCannot be converted to bool.)rxr��bool)rqr!r!r"�__bool__�szFieldStorage.__bool__cCs�|jj|j�}t|t�sFtd|jt|�jf��|j|j	|j
�}|jrx|d|j7}g|_t
jj||j|jd|j	d|j
�}x-|D]%\}}|jjt||��q�W|j�dS)Nz%s should return bytes, got %sr1r*r�)r?r;r�r6rWr:ryrtr<r*r�r�rxr>rr
rArBrTr	�
skip_lines)rqrF�queryr\rpr!r!r"r��s			zFieldStorage.read_urlencodedc
Cs~|j}t|�s(td|f��g|_|jr�tjj|j|j|j	d|j
d|j�}x-|D]%\}}|jjt
||��qtW|jp�|j}|jj�}	t|	t�s�td|jt|	�jf��|jt|	�7_xG|	j�d|jkrM|	rM|jj�}	|jt|	�7_qWxt�}
d}x*|jj�}||7}|j�scPqcW|s�P|jt|�7_|
j|j|j
|j��|
j�}
d|
kr�|
d=||j|
|||||j|j|j
|j�	}|j|j7_|jj|�|jsk|j|jkofdknrQPqQW|j �dS)	Nz&Invalid boundary in multipart form: %rr*r�z%s should return bytes, got %ss--rIzcontent-lengthr)!r�rNr:rxr�r>rr
rArBr*r�rTr	�FieldStorageClass�	__class__r?rQr6rWryrtr�rbrcrZfeedr<r(r�r�r�r�)rqr@rArBZibr�r\rp�klassZ
first_line�parserZhdr_textrXrY�partr!r!r"r��sV					
+zFieldStorage.read_multicCsD|jdkr&|j�|j�n
|j�|jjd�dS)Nr)r��read_binaryr��
read_linesrzr�)rqr!r!r"r��s



zFieldStorage.read_single�icCs�|j�|_|j}|dkr�x�|dkr�|jjt||j��}t|t�s�t	d|jt
|�jf��|jt
|�7_|s�d|_P|jj|�|t
|�}q'WdS)Nrz%s should return bytes, got %sr2rL)�	make_filerzr�r?r;�min�bufsizer6rWr:ryrtr�rbr�r%)rqZtodorXr!r!r"r��s		zFieldStorage.read_binarycCsV|jrt�|_|_nt�|_|_|jrH|j�n
|j�dS)N)r�rrz�_FieldStorage__filerr��read_lines_to_outerboundary�read_lines_to_eof)rqr!r!r"r��s		
zFieldStorage.read_linescCs�|jdk	re|jj�t|�dkre|j�|_|jj�}|jj|�d|_|jr�|jj|�n"|jj|j|j	|j
��dS)Ni�)r��tellrbr�rzr�r%r�r<r*r�)rqr[rXr!r!r"Z__writes		zFieldStorage.__writecCsOxH|jjd�}|jt|�7_|s:d|_P|j|�qWdS)Nr2�irL)r?rQr�rbr��_FieldStorage__write)rqr[r!r!r"r�s	zFieldStorage.read_lines_to_eofc	Cs�d|j}|d}d}d}d}xh||jkr<P|jjd�}|jt|�7_|t|�7}|s�d
|_P|dkr�||}d}|jd�r�|r�|j�}||kr�P||kr�d|_P|}|j	d�rd}|dd�}d}nh|j	d
�rEd
}|dd�}d}n:|j	d�rsd}|dd�}d}nd}d}|j
||�q,WdS)Ns--rITrr2r�s
s
rGs
FirLrMrLrL)r�r�r?rQr�rbr�rRrS�endswithr�)	rq�
next_boundary�
last_boundary�delim�last_line_lfend�_readr[�strippedlineZodelimr!r!r"r�!sP

	
				z(FieldStorage.read_lines_to_outerboundarycCs�|js|jrdSd|j}|d}d}x�|jjd�}|jt|�7_|snd|_P|jd�r�|r�|j�}||kr�P||kr�d|_P|jd�}q7WdS)Ns--Tr2r�s
irL)r�r�r?rQr�rbr�rc)rqr�r�r�r[r�r!r!r"r�Rs&

		zFieldStorage.skip_linescCs6|jrtjd�Stjdd|jdd�SdS)Nzwb+zw+r*�newliner$)r��tempfile�
TemporaryFiler*)rqr!r!r"r�hs	
zFieldStorage.make_filei ) rtrurv�osr@rrr�r�r�rsr�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:+	�
6	
1cCs�td�t�tjt_ybt�}t�t�t|�t|�t	�dd�}|dd�}td�|�Wnt
�YnXtd�day/t�}t�t�t|�t|�Wnt
�YnXdS)	NzContent-type: text/htmlcSstd�dS)Nz,testing print_exception() -- <I>italics?</I>)�execr!r!r!r"rf�sztest.<locals>.fcSs|�dS)Nr!)rfr!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@�formrfr�r!r!r"�test�s4
	



	
r�cCs�|dkr!tj�\}}}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>rr2rLrL)	r3�exc_info�	tracebackr��	format_tb�format_exception_only�htmlrrU)ryrp�tbr�r�rxr!r!r"r�s
cCs|t|j��}t�td�td�x7|D]/}tdtj|�dtj||��q4Wtd�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�|s3td�td�x}|D]u}tdtj|�ddd�||}tdtjtt|���d	�td
tjt|���qDWtd�t�dS)Nz<H3>Form Contents:</H3>z<P>No form fields.z<DL>z<DT>�:re� z<i>z</i>z<DD>z</DL>)r�r�r�r�r�reprry)r�r�r\rpr!r!r"r�s



!
'!
cCs�t�td�ytj�}WnAtk
rd}z!tdtjt|���WYdd}~XnXttj|��t�dS)Nz#<H3>Current Working Directory:</H3>zOSError:)r�r��getcwdrr�r�str)�pwd�msgr!r!r"r�s
/cCs0t�td�t�ttj�t�dS)Nz <H3>Command Line Arguments:</H3>)r�r3r=r!r!r!r"r�s


cCstd�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'cCsetdtdd�|jdd�}|jdd�}|jdd	�}|ra|jd
d�}|S)Nz1cgi.escape is deprecated, use html.escape instead�
stacklevelrGr1z&amp;�<z&lt;�>z&gt;r_z&quot;)rrHrl)rd�quoter!r!r"rs
cCs:ddl}t|t�r$d}nd}|j||�S)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)�rer6rW�match)rdr�Z_vb_patternr!r!r"rN(s
	rN�__main__)0�__version__�iorrr�collectionsrr3r�Zurllib.parser>Zemail.parserrZ
email.messager�warningsrr�r�r��__all__rrr#rrr)rr9r@rrr
rrgrr	r
r�rrrrrrrrNrtr!r!r!r"�<module>sZ		#	Ed��"'/

Zerion Mini Shell 1.0