ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/__pycache__/cgi.cpython-311.pyc

�

�f�����dZdZddlmZmZmZddlmZddlZddl	Z	ddl
Zddlm
Z
ddlmZddlZddlZddlZddlZgd�Zejed	�
��dadad�Zd
�Zd�Zd�Zeadade	jdddfd�Z d$d�Z!d�Z"d�Z#Gd�d��Z$Gd�d��Z%e	jfd�Z&d%d�Z'e	jfd�Z(d�Z)d�Z*d �Z+d!�Z,d"�Z-ed#kre&��dSdS)&a�Support module for CGI (Common Gateway Interface) scripts.

This module defines a number of utilities for use by CGI scripts
written in Python.

The global variable maxlen can be set to an integer indicating the maximum size
of a POST request. POST requests larger than this size will result in a
ValueError being raised during parsing. The default value of this variable is 0,
meaning the request size is unlimited.
z2.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)��
)�remove�c���tjdtd���tr0ts)	ttdd���an#t$rYnwxYwtstantat|�dS)a�Write a log message, if there is a log file.

    Even though this function is called initlog(), you should always
    use log(); log is a variable that is set either to initlog
    (initially), to dolog (once the log file has been opened), or to
    nolog (when logging is disabled).

    The first argument is a format string; the remaining arguments (if
    any) are arguments to the % operator, so e.g.
        log("%s: %s", "a", "b")
    will write "a: b" to the log file, followed by a newline.

    If the global logfp is not None, it should be a file object to
    which log data is written.

    If the global logfp is None, the global logfile may be a string
    giving a filename to open, in append mode.  This file should be
    world writable!!!  If the file can't be opened, logging is
    silently disabled (since there is no safe place where we could
    send an error message).

    z7cgi.log() is deprecated as of 3.10. Use logging instead�)�
stacklevel�a�locale)�encodingN)
�warnings�warn�DeprecationWarning�logfile�logfp�open�OSError�nolog�log�dolog��allargss �*/opt/alt/python311/lib64/python3.11/cgi.py�initlogr,As���0
�M�K�$��4�4�4�4���u��	���#��9�9�9�E�E���	�	�	��D�	�������������M�M�M�Ms�A�
A�Ac�F�t�||zdz��dS)z=Write a log message to the log file.  See initlog() for docs.�
N)r#�write)�fmt�argss  r+r(r(fs"��	�K�K��D��4�� � � � � �c��dS)z9Dummy function, assigned to log when logging is disabled.N�r)s r+r&r&js���Dr2c�\�datrt���datadS)zClose the log file.rN)r"r#�closer,r'r4r2r+�closelogr7ns,���G���
���
�
�
���
�C�C�Cr2�&c�:�|�tj}t|d��r|j}nd}t	|t
��r|j}d|vrd|d<|ddkr�t|d��\}}|dkrt|||�	��S|d
kr_t|d��}tr|tkrtd���|�|���
|��}	nd
}	d|vr|	r|	dz}	|	|dz}	n0tjdd�r|	r|	dz}	|	tjdz}	|	|d<n;d|vr	|d}	n.tjdd�rtjd}	nd
}	|	|d<tj�|	||||���S)a�Parse a query in the environment or from a file (default stdin)

        Arguments, all optional:

        fp              : file pointer; default: sys.stdin.buffer

        environ         : environment dictionary; default: os.environ

        keep_blank_values: flag indicating whether blank values in
            percent-encoded forms should be treated as blank strings.
            A true value indicates that blanks should be retained as
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.

        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.

        separator: str. The symbol to use for separating the query arguments.
            Defaults to &.
    Nrzlatin-1�REQUEST_METHOD�GET�POST�CONTENT_TYPEzmultipart/form-data)�	separator�!application/x-www-form-urlencoded�CONTENT_LENGTH�Maximum content length exceededr�QUERY_STRINGr8�)rr>)�sys�stdin�hasattrr�
isinstancer�bufferr
r�int�maxlen�
ValueError�read�decode�argv�urllibr�parse_qs)
�fp�environ�keep_blank_values�strict_parsingr>r�ctype�pdict�clength�qss
          r+rr�s���0
�z�
�Y���r�*�����;������"�m�$�$��
�Y���w�&�&�$)�� �!��� �F�*�*�#�G�N�$;�<�<���u��)�)�)�"�2�u�	�B�B�B�B�
�9�
9�
9��'�"2�3�4�4�G��
D�'�F�*�*� �!B�C�C�C�����!�!�(�(��2�2�B�B��B��W�$�$�� ��S��2��g�n�-�-�B�B�
�X�a�b�b�\�	"�� ��S��2��c�h�q�k�!�B�"$�����	�7�	"�	"�
�^�
$����8�A�B�B�<�	���!��B�B��B�"$�����<� � ��%6��*2�i�!�I�I�Ir2�utf-8�replacec�.��|d�d��}d�|��}t��}|�|��	|d|d<n#t$rYnwxYwt||||ddi|�����fd	��D��S)
a�Parse multipart input.

    Arguments:
    fp   : input file
    pdict: dictionary containing other parameters of content-type header
    encoding, errors: request encoding and error handler, passed to
        FieldStorage

    Returns a dictionary just like parse_qs(): keys are the field names, each
    value is a list of values for that field. For non-file fields, the value
    is a list of strings.
    �boundary�asciiz multipart/form-data; boundary={}zCONTENT-LENGTHzContent-Lengthr:r<)�headersr�errorsrRr>c�<��i|]}|��|����Sr4)�getlist)�.0�k�fss  �r+�
<dictcomp>z#parse_multipart.<locals>.<dictcomp>�s%���)�)�)��A�r�z�z�!�}�}�)�)�)r2)rM�formatr�set_type�KeyErrorr
)	rQrVrr_r>r\rUr^rds	        @r+rr�s�����Z� �'�'��0�0�H�.�5�5�h�?�?�E��i�i�G����U����
�$)�*:�$;�� �!�!���
�
�
���
����	�b�'�H�V�!�6�*�i�
A�
A�
A�B�)�)�)�)�b�)�)�)�)s�A"�"
A/�.A/c#�K�|dd�dkr�|dd�}|�d��}|dkr�|�dd|��|�dd|��z
dzrQ|�d|dz��}|dkr2|�dd|��|�dd|��z
dz�Q|dkrt|��}|d|�}|���V�||d�}|dd�dk��dSdS)NrC�;r�"�\"r)�find�count�len�strip)�s�end�fs   r+�_parseparamrt�s����
�B�Q�B�%�3�,�,�
�a�b�b�E���f�f�S�k�k���A�g�g�1�7�7�3��3�/�/�!�'�'�%��C�2H�2H�H�A�M�g��&�&��c�A�g�&�&�C��A�g�g�1�7�7�3��3�/�/�!�'�'�%��C�2H�2H�H�A�M�g���7�7��a�&�&�C�
�d�s�d�G���g�g�i�i����
�c�d�d�G���B�Q�B�%�3�,�,�,�,�,�,r2c��td|z��}|���}i}|D]�}|�d��}|dkr�|d|�������}||dzd����}t|��dkrP|d|dcxkrdkr7nn4|dd�}|�d	d
���dd��}|||<��||fS)zfParse a Content-type like header.

    Return the main content-type and a dictionary of options.

    rj�=rNrCr���rkz\\�\rl)rt�__next__rmrp�lowerrorZ)�line�parts�keyrV�p�i�name�values        r+r
r
�s��
��d�
�#�#�E�
�.�.�
�
�C��E�
� � ��
�F�F�3�K�K����6�6��R�a�R�5�;�;�=�=�&�&�(�(�D��a��c�d�d�G�M�M�O�O�E��5�z�z�Q���5��8�u�R�y�#?�#?�#?�#?�C�#?�#?�#?�#?�#?��a��d����
�
�f�d�3�3�;�;�E�3�G�G���E�$�K����:�r2c�>�eZdZdZdZdZdZdZiZdZ	iZ
iZd�Zd�Z
dS)r	z=Like FieldStorage, for use when no file uploads are possible.Nc�"�||_||_dS)z&Constructor from field name and value.N�r�r���selfr�r�s   r+�__init__zMiniFieldStorage.__init__s����	���
�
�
r2c�(�d|j�d|j�d�S)z Return printable representation.zMiniFieldStorage(�, �)r��r�s r+�__repr__zMiniFieldStorage.__repr__s���-1�Y�Y�Y��
�
�
�C�Cr2)�__name__�
__module__�__qualname__�__doc__�filename�list�type�file�type_options�disposition�disposition_optionsr^r�r�r4r2r+r	r	sh������G�G��H��D��D��D��L��K����G����D�D�D�D�Dr2r	c���eZdZdZdddejdddddddfd�Zd	�Zd
�Zd�Z	d�Z
d
�Zd�Zd�Z
d"d�Zd"d�Zd�Zd�Zd�Zd�Zd�Zd�ZdZd�Zd�ZdZd�Zd�Zd�Zd�Zd�Zd �Zd!�Z dS)#r
a�Store a sequence of fields, reading multipart/form-data.

    This class provides naming, typing, files stored on disk, and
    more.  At the top level, it is accessible like a dictionary, whose
    keys are the field names.  (Note: None can occur as a field name.)
    The items are either a Python list (if there's multiple values) or
    another FieldStorage or MiniFieldStorage object.  If it's a single
    object, it has the following attributes:

    name: the field name, if specified; otherwise None

    filename: the filename, if specified; otherwise None; this is the
        client side filename, *not* the file name on which it is
        stored (that's a temporary file you don't deal with)

    value: the value as a *string*; for file uploads, this
        transparently reads the file every time you request the value
        and returns *bytes*

    file: the file(-like) object from which you can read the data *as
        bytes* ; None if the data is stored a simple string

    type: the content-type, or None if not specified

    type_options: dictionary of options specified on the content-type
        line

    disposition: content-disposition, or None if not specified

    disposition_options: dictionary of corresponding options

    headers: a dictionary(-like) object (sometimes email.message.Message or a
        subclass thereof) containing *all* headers

    The class is subclassable, mostly for the purpose of overriding
    the make_file() method, which is called internally to come up with
    a file open for reading and writing.  This makes it possible to
    override the default choice of storing all files in a temporary
    directory and unlinking them as soon as they have been opened.

    Nr2rrYrZr8c��d}||_||_|
|_||_d|vr|d���}d|_|dks|dkrrd|vr	|d}
n)tjdd�rtjd}
nd}
|
�tj
��d��}
t|
��}|�d	d
i}|�=i}|dkrd
|d	<d|vr|d|d	<d|vr
|d|_d
|vr|d
|d<n+t|ttf��std���||_|�tjj|_nXt|t(��r
|j|_n6t+|d��rt+|d��std���||_||_|	|_t|t0��s$tdt3|��jz���||_d|_||_di}}d|jvrt=|jd��\}}||_||_ d|_!d|vr
|d|_!d|_"d|vr
|d|_"|j"du|_#d	|jvrt=|jd	��\}}n|js|dkrdi}}nd
i}}||_||_$d|vr,|d�|j|j��|_%nd|_%d}d|jvrM	tM|jd��}n#tN$rYnwxYwtPr|tPkrtOd���||_)|j�
|dkr||_dx|_*|_+d|_,|d
kr|�-��dS|dd�dkr|�.|||��dS|�/��dS)a$Constructor.  Read multipart/* until last part.

        Arguments, all optional:

        fp              : file pointer; default: sys.stdin.buffer
            (not used when the request method is GET)
            Can be :
            1. a TextIOWrapper object
            2. an object whose read() and readline() methods return bytes

        headers         : header dictionary-like object; default:
            taken from environ as per CGI spec

        outerboundary   : terminating multipart boundary
            (for internal use only)

        environ         : environment dictionary; default: os.environ

        keep_blank_values: flag indicating whether blank values in
            percent-encoded forms should be treated as blank strings.
            A true value indicates that blanks should be retained as
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.

        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.

        limit : used internally to read parts of multipart/form-data forms,
            to exit from the reading loop when reached. It is the difference
            between the form content-length and the number of bytes already
            read

        encoding, errors : the encoding and error handler used to decode the
            binary stream to strings. Must be the same as the charset defined
            for the page sending the form (content-type : meta http-equiv or
            header)

        max_num_fields: int. If set, then __init__ throws a ValueError
            if there are more than n fields read by parse_qsl().

        r;r:N�HEADrBrCr�surrogateescapezcontent-typer?r<r=r@�content-lengthz?headers must be mapping or an instance of email.message.MessagerL�readlinezfp must be file pointerz#outerboundary must be bytes, not %srzcontent-dispositionr�r�z
text/plainr\r2rwrA�
z
multipart/)0rSrT�max_num_fieldsr>�upper�
qs_on_postrDrN�encoder�getpreferredencodingrrGrr�	TypeErrorr^rErHrQrrFrr_�bytesr�r��
outerboundary�
bytes_read�limitr
r�r�r�r��_binary_filer��
innerboundaryrIrKrJ�lengthr�r��done�read_urlencoded�
read_multi�read_single)r�rQr^r�rRrSrTr�rr_r�r>�methodrX�cdisprVrU�clens                  r+r�zFieldStorage.__init__Js|��^��!2���,���,���"����w�&�&��-�.�4�4�6�6�F�����U�?�?�f��.�.���(�(��^�,�����!�"�"��
��X�a�[��������6�6�8�8�:K�L�L�B�����B���)�>�@���?��G�����*M���'���(�(�*1�.�*A���'���(�(�")�.�"9����7�*�*�,3�4D�,E��(�)���w��'�(:�;�;�
9��!8�9�9�9����
�:��i�&�D�G�G�
��M�
*�
*�	��i�D�G�G��B��'�'�
;�G�B�
�,C�,C�
;�� 9�:�:�:��D�G� ��
�����-��/�/�	<��A�"�=�1�1�:�;�<�<�
<�*��������
��2�u�� �D�L�0�0�'���5J�(K�L�L�L�E�5� ���#(�� ���	��U�?�?��f�
�D�I���
�����!�*�-�D�M� �M��5����T�\�)�)�'���^�(D�E�E�L�E�5�5�
�
�	C�6�V�#3�#3�'��5�E�E�>��5�E���	�!�������!&�z�!2�!9�!9�$�-�:>�+�"G�"G�D���"%�D�����t�|�+�+�
��4�<�(8�9�:�:�����
�
�
���
�����
D�$��-�-� �!B�C�C�C�����:��$�!�)�)��D�J� $�$��	�D�I���	��7�7�7�� � �"�"�"�"�"�
�3�B�3�Z�<�
'�
'��O�O�G�%6��G�G�G�G�G��������s�L�
L,�+L,c�\�	|j���dS#t$rYdSwxYw�N)r�r6�AttributeErrorr�s r+�__del__zFieldStorage.__del__�sA��	��I�O�O��������	�	�	��D�D�	���s��
+�+c��|Sr�r4r�s r+�	__enter__zFieldStorage.__enter__�s���r2c�8�|j���dSr�)r�r6)r�r1s  r+�__exit__zFieldStorage.__exit__�s���	�������r2c�8�d|j�d|j�d|j�d�S)z"Return a printable representation.z
FieldStorage(r�r�)r�r�r�r�s r+r�zFieldStorage.__repr__�s)����	�	�	�4�=�=�=�$�*�*�*�6�	6r2c�D�t|�����Sr�)�iter�keysr�s r+�__iter__zFieldStorage.__iter__s���D�I�I�K�K� � � r2c��|dkrt|���|jrN|j�d��|j���}|j�d��n|j�|j}nd}|S)Nr�r)r�r��seekrLr�r�s   r+�__getattr__zFieldStorage.__getattr__sz���7�?�?� ��&�&�&��9�	��I�N�N�1�����I�N�N�$�$�E��I�N�N�1�����
�Y�
"��I�E�E��E��r2c���|j�td���g}|jD]"}|j|kr|�|���#|st	|���t|��dkr|dS|S)zDictionary style indexing.N�
not indexablerCr)r�r�r��appendrhro)r�r}�found�items    r+�__getitem__zFieldStorage.__getitem__s~���9���O�,�,�,����I�	4�	4�D��y�C������d�!3�!3�!3���	 ��3�-�-���u�:�:��?�?���8�O��Lr2c�n�||vr0||}t|t��rd�|D��S|jS|S)z8Dictionary style get() method, including 'value' lookup.c��g|]	}|j��
Sr4�r��rb�xs  r+�
<listcomp>z)FieldStorage.getvalue.<locals>.<listcomp>#���/�/�/�A���/�/�/r2�rGr�r��r�r}�defaultr�s    r+�getvaluezFieldStorage.getvaluesG���$�;�;���I�E��%��&�&�
#�/�/��/�/�/�/��{�"��Nr2c�p�||vr1||}t|t��r
|djS|jS|S)z! Return the first value received.rr�r�s    r+�getfirstzFieldStorage.getfirst)s?���$�;�;���I�E��%��&�&�
#��Q�x�~�%��{�"��Nr2c�p�||vr1||}t|t��rd�|D��S|jgSgS)z  Return list of received values.c��g|]	}|j��
Sr4r�r�s  r+r�z(FieldStorage.getlist.<locals>.<listcomp>9r�r2r�)r�r}r�s   r+razFieldStorage.getlist4sI���$�;�;���I�E��%��&�&�
%�/�/��/�/�/�/���}�$��Ir2c��|j�td���ttd�|jD������S)zDictionary style keys() method.Nr�c3�$K�|]}|jV��dSr��r�)rbr�s  r+�	<genexpr>z$FieldStorage.keys.<locals>.<genexpr>Cs$����8�8�d��	�8�8�8�8�8�8r2)r�r��setr�s r+r�zFieldStorage.keys?s?���9���O�,�,�,��C�8�8�d�i�8�8�8�8�8�9�9�9r2c�p��|j�td���t�fd�|jD����S)z%Dictionary style __contains__ method.Nr�c3�.�K�|]}|j�kV��dSr�r�)rbr�r}s  �r+r�z,FieldStorage.__contains__.<locals>.<genexpr>Is*�����:�:��4�9��#�:�:�:�:�:�:r2)r�r��any)r�r}s `r+�__contains__zFieldStorage.__contains__Es>����9���O�,�,�,��:�:�:�:��	�:�:�:�:�:�:r2c�D�t|�����S)z Dictionary style len(x) support.)ror�r�s r+�__len__zFieldStorage.__len__Ks���4�9�9�;�;���r2c�V�|j�td���t|j��S)NzCannot be converted to bool.)r�r��boolr�s r+�__bool__zFieldStorage.__bool__Os'���9���:�;�;�;��D�I���r2c	��|j�|j��}t|t��s+t|j�dt
|��j�����|�|j	|j
��}|jr
|d|jzz
}tj
�||j|j|j	|j
|j|j���}d�|D��|_|���dS)z+Internal: read data in query string format.� should return bytes, got r8�rr_r�r>c�4�g|]\}}t||����Sr4�r	�rbr}r�s   r+r�z0FieldStorage.read_urlencoded.<locals>.<listcomp>as'��J�J�J�j�c�5�%�c�5�1�1�J�J�Jr2N)rQrLr�rGr�rKr�r�rMrr_r�rOr�	parse_qslrSrTr�r>r��
skip_lines)r�rX�querys   r+r�zFieldStorage.read_urlencodedTs���
�W�\�\�$�+�
&�
&���"�e�$�$�	=�� $�����b���):�):�<�=�=�
=�
�Y�Y�t�}�d�k�
2�
2���?�	(��#���'�'�B���&�&���&��(;��]�4�;��.�$�.�'�J�J��K�J�E�J�J�J��	��������r2c
��|j}t|��std|�����g|_|jrmt
j�|j|j|j	|j
|j|j|j
���}|j�d�|D����|jp|j}|j���}t'|t(��s+t|j�dt+|��j�����|xjt1|��z
c_|���d|jzkrZ|rX|j���}|xjt1|��z
c_|���d|jzkr|�X|j}|�|t1|j��z}	t5��}	d}
	|j���}|
|z
}
|���sn�4|
s�n9|xjt1|
��z
c_|	�|
�|j
|j����|	���}d	|vr|d	=|j�dn|j|jz
}
||j||||||
|j
|j||j
��}|�8|d
z}|jr|t1|j��z}|dkrtd���|xj|jz
c_|j�|��|j s|j|j!cxkrdkrnnn���|�"��dS)
z/Internal: read a part that is itself multipart.z$Invalid boundary in multipart form: r�c3�<K�|]\}}t||��V��dSr�r�r�s   r+r�z*FieldStorage.read_multi.<locals>.<genexpr>qs1����R�R�j�c�5�-�c�5�9�9�R�R�R�R�R�Rr2r��--NTr2r�rCrzMax number of fields exceeded)#r��valid_boundaryrKr�r�rOrr�rSrTrr_r�r>�extend�FieldStorageClass�	__class__rQr�rGr�r�r�r�rorpr�feedrMr6r�r�r�r�r�)r�rRrSrT�ibr��klass�
first_liner��parser�hdr_text�datar^r��parts               r+r�zFieldStorage.read_multifs���
�
���b�!�!�	O��*���M�N�N�N���	��?�	S��L�*�*����!7��9L���t�{�#�2�d�n�+�N�N�E�
�I���R�R�E�R�R�R�R�R�R��&�8�$�.���W�%�%�'�'�
��*�e�,�,�	E�� $�����j�)9�)9�)B�)B�D�E�E�
E����3�z�?�?�*������!�!�e�d�.@�&@�A�A��B���)�)�+�+�J��O�O�s�:���.�O�O����!�!�e�d�.@�&@�A�A��B��,���%��c�$�)�n�n�,�N�#	��\�\�F��H�
��w�'�'�)�)���D� ���z�z�|�|���	
�
�
���O�O�s�8�}�}�,�O�O��K�K�����
�t�{�C�C�D�D�D��l�l�n�n�G� �7�*�*��,�-� �J�.�D�D��Z�$�/�1�
��5���'�2�w�8I�'������^�T�^�U�U�D��)��!�#���9�5�"�c�$�)�n�n�4�N�!�A�%�%�$�%D�E�E�E��O�O�t��.�O�O��I���T�"�"�"��y�
�D�O�t�{�>�>�>�>�Q�>�>�>�>�>��G#	�H	
�������r2c���|jdkr)|���|���n|���|j�d��dS)zInternal: read an atomic part.rN)r��read_binaryr��
read_linesr�r�r�s r+r�zFieldStorage.read_single�s^���;�!����������O�O������O�O�����	���q�����r2i c���|���|_|j}|dkr�|dkr�|j�t||j����}t|t��s+t|j�dt|��j�����|xjt|��z
c_|s	d|_dS|j�|��|t|��z
}|dk��dSdSdS)zInternal: read binary data.rr�rwN)�	make_filer�r�rQrL�min�bufsizerGr�rKr�r�r�ror�r/)r��todor�s   r+r�zFieldStorage.read_binary�s����N�N�$�$��	��{���1�9�9���(�(��w�|�|�C��d�l�$;�$;�<�<��!�$��.�.�G�$�(,�����d���1D�1D�&F�G�G�G����3�t�9�9�,����� "�D�I��E��	����%�%�%��c�$�i�i�'����(�(�(�(��9��(r2c���|jrt��x|_|_nt	��x|_|_|jr|���dS|���dS)z0Internal: read lines until EOF or outerboundary.N)r�rr��_FieldStorage__filerr��read_lines_to_outerboundary�read_lines_to_eofr�s r+rzFieldStorage.read_lines�sn����	1�&-�i�i�/�D�I����&.�j�j�0�D�I�����	%��,�,�.�.�.�.�.��"�"�$�$�$�$�$r2c���|j��|j���t|��zdkrS|���|_|j���}|j�|��d|_|jr|j�|��dS|j�|�|j	|j
����dS)z line is always bytes, not stringNi�)r�tellrorr�r�r/r�rMrr_)r�r{r�s   r+�__writezFieldStorage.__write�s����;�"��{���!�!�C��I�I�-��4�4� �N�N�,�,��	��{�+�+�-�-���	����%�%�%�"�����	E��I�O�O�D�!�!�!�!�!�
�I�O�O�D�K�K��
�t�{�C�C�D�D�D�D�Dr2c��	|j�d��}|xjt|��z
c_|s	d|_dS|�|���X)zInternal: read lines until EOF.rC�rwN)rQr�r�ror��_FieldStorage__write)r�r{s  r+r	zFieldStorage.read_lines_to_eof�s]��	��7�#�#�E�*�*�D��O�O�s�4�y�y�(�O�O��
���	����L�L�����
	r2c���d|jz}|dz}d}d}d}	|j�d|jcxkr|krnndS|j�d��}|xjt|��z
c_|t|��z
}|s	d|_dS|d	kr||z}d}|�d��r-|r+|���}||krdS||kr	d|_dS|}|�	d
��rd
}|dd�}d}nL|�	d��rd}|dd�}d}n(|�	d	��rd	}|dd�}d
}nd}d
}|�
||z����M)z�Internal: read lines until outerboundary.
        Data is read as bytes: boundaries and line ends must be converted
        to bytes for comparisons.
        r�r2TrrCNrrw�
s
����
F)r�r�rQr�r�ror��
startswith�rstrip�endswithr)	r��
next_boundary�
last_boundary�delim�last_line_lfend�_readr{�strippedline�odelims	         r+rz(FieldStorage.read_lines_to_outerboundary�s���
�� 2�2�
�%��-�
�������&	(��z�%�!�t�z�*B�*B�*B�*B�U�*B�*B�*B�*B�*B����7�#�#�E�*�*�D��O�O�s�4�y�y�(�O�O��S��Y�Y��E��
���	�����~�~��t�|�������u�%�%�
�/�
�#�{�{�}�}���=�0�0��E��=�0�0� !�D�I��E��F��}�}�W�%�%�
(����C�R�C�y��"&������u�%�%�
(����C�R�C�y��"&������u�%�%�
(����C�R�C�y��"'�����"'���L�L��$��'�'�'�M&	(r2c�z�|jr|jrdSd|jz}|dz}d}	|j�d��}|xjt|��z
c_|s	d|_dS|�d��r-|r+|���}||krdS||kr	d|_dS|�d��}��)z5Internal: skip lines until outer boundary if defined.Nr�TrrwrCr)r�r�rQr�r�rorrp)r�rrrr{rs      r+r�zFieldStorage.skip_liness����!�	�T�Y�	��F��� 2�2�
�%��-�
���
	3��7�#�#�E�*�*�D��O�O�s�4�y�y�(�O�O��
���	����}�}�U�#�#�
��
�#�z�z�|�|���=�0�0��E��=�0�0� !�D�I��E�"�m�m�E�2�2�O�
	3r2c�p�|jrtjd��Stjd|jd���S)a�Overridable: return a readable & writable file.

        The file will be used as follows:
        - data is written to it
        - seek(0)
        - data is read from it

        The file is opened in binary mode for files, in text mode
        for other fields

        This version opens a temporary file for reading and writing,
        and immediately deletes (unlinks) it.  The trick (on Unix!) is
        that the file can still be used, but it can't be opened by
        another process, and it will automatically be deleted when it
        is closed or when the current process terminates.

        If you want a more permanent file, you derive a class which
        overrides this method.  If you want a visible temporary file
        that is nevertheless automatically deleted when the script
        terminates, try defining a __del__ method in a derived class
        which unlinks the temporary files you have created.

        zwb+zw+r.)r�newline)r��tempfile�
TemporaryFilerr�s r+rzFieldStorage.make_file3sC��0��	8��)�%�0�0�0��)�$���$�8�8�8�
8r2r�)!r�r�r�r��osrRr�r�r�r�r�r�r�r�r�r�rar�r�r�r�r�r�r�r�rr�rrr	rr�rr4r2r+r
r
s�������(�(�R��C���q���g�i� $��c�c�c�c�J���������6�6�6�
!�!�!�������	�	�	�	�	�	�	�	�	�	�	�:�:�:�;�;�;� � � ����
��� ��C�C�C�J����G�(�(�(�"	%�	%�	%�
E�
E�
E����0(�0(�0(�d3�3�3�,8�8�8�8�8r2r
c�h�td��t��tjt_	t	��}t��t
��t|��t|��t��d�}|fd�}td��|��n#t��YnxYwtd��da	t	��}t��t
��t|��t|��dS#t��YdSxYw)z�Robust test CGI script, usable as main program.

    Write minimal HTTP headers and dump all information provided to
    the script in HTML form.

    zContent-type: text/htmlc�$�td��dS)Nz,testing print_exception() -- <I>italics?</I>)�execr4r2r+rsztest.<locals>.ffs���?�@�@�@�@�@r2c��|��dSr�r4)rss r+�gztest.<locals>.ghs��
�A�C�C�C�C�Cr2z9<H3>What follows is a test, not an actual exception:</H3>z*<H1>Second try with a small maxlen...</H1>�2N)�printrD�stdout�stderrr
rrrrrrrJ)rR�formrsr(s    r+rrUsO��
�
#�$�$�$�	�G�G�G���C�J���~�~�����������4�����g��������	A�	A�	A��	�	�	�	�
�I�J�J�J�	�����������������	�
6�7�7�7��F���~�~�����������4�����g�����������������s�A7B-�-B?�AD�D1c
��|�tj��\}}}ddl}t��td��|�||��|�||��z}tdt
jd�|dd������dt
j|d���d���~dS)Nrz+<H3>Traceback (most recent call last):</H3>z<PRE>rrwz<B>z
</B></PRE>)	rD�exc_info�	tracebackr*�	format_tb�format_exception_only�html�escape�join)r�r��tbr�r0r�s      r+rr|s����|��,�.�.���e�R�����	�G�G�G�	�
7�8�8�8����r�5�)�)��*�*�4��7�7�8�D�	�E���B�G�G�D��"��I�&�&�'�'�'�'���D��H�����
����	��r2c
�\�t|�����}t��td��td��|D]>}tdtj|��dtj||�����?td��t��dS)z#Dump the shell environment as HTML.z<H3>Shell Environment:</H3>�<DL>�<DT>�<DD>�</DL>N)�sortedr�r*r3r4)rRr�r}s   r+rr�s����'�,�,�.�.�!�!�D�	�G�G�G�	�
'�(�(�(�	�&�M�M�M��K�K��
�f�d�k�#�&�&����G�C�L�0I�0I�J�J�J�J�	�'�N�N�N�	�G�G�G�G�Gr2c�L�t|�����}t��td��|std��td��|D]�}tdtj|��zdzd���||}tdtjtt
|������zd	z��td
tjt|����z����td��t��dS)
z$Dump the contents of a form as HTML.z<H3>Form Contents:</H3>z<P>No form fields.r8r9�:� )rrz<i>z</i>r:r;N)r<r�r*r3r4�reprr�)r-r�r}r�s    r+rr�s����$�)�)�+�+���D�	�G�G�G�	�
#�$�$�$��$�
�"�#�#�#�	�&�M�M�M��1�1��
�f�t�{�3�'�'�'�#�-�3�7�7�7�7��S�	��
�e�d�k�$�t�E�{�{�"3�"3�4�4�4�v�=�>�>�>�
�f�t�{�4��;�;�/�/�/�0�0�0�0�	�'�N�N�N�	�G�G�G�G�Gr2c	�T�t��td��	tj��}ttj|����nF#t
$r9}tdtjt
|������Yd}~nd}~wwxYwt��dS)z#Dump the current directory as HTML.z#<H3>Current Working Directory:</H3>zOSError:N)r*r#�getcwdr3r4r%�str)�pwd�msgs  r+rr�s���	�G�G�G�	�
/�0�0�0� ��i�k�k��	�d�k�#���������1�1�1�
�j�$�+�c�#�h�h�/�/�0�0�0�0�0�0�0�0�����1����
�G�G�G�G�Gs�A�
B�/B�Bc��t��td��t��ttj��t��dS)Nz <H3>Command Line Arguments:</H3>)r*rDrNr4r2r+rr�s=��	�G�G�G�	�
,�-�-�-�	�G�G�G�	�#�(�O�O�O�	�G�G�G�G�Gr2c�$�td��dS)z9Dump a list of environment variables used by CGI as HTML.a�
<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>
N)r*r4r2r+rr�s#��	�'�'�'�'�'�'r2c�j�ddl}t|t��rd}nd}|�||��S)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)�rerGr��match)rqrI�_vb_patterns   r+r�r��s=��
�I�I�I��!�U���,�,���+��
�8�8�K��#�#�#r2�__main__)rYrZr8)NNNN).r��__version__�iorrr�collections.abcrrDr#�urllib.parserO�email.parserr�
email.messagerr3rr!r�__all__�_deprecatedr�r"r#r,r(r&r7r'rJrRrrrtr
r	r
rrrrrrrr�r4r2r+�<module>rUs���	�	�*��0�/�/�/�/�/�/�/�/�/�#�#�#�#�#�#�
�
�
�
�	�	�	�	�����#�#�#�#�#�#�!�!�!�!�!�!�����
�
�
�
���������"�"�"�����X�f�-�-�-�-�

����#�#�#�J!�!�!�	�	�	������
��
�2�:���c�CI�CI�CI�CI�L*�*�*�*�6
�
�
����0D�D�D�D�D�D�D�D�2p8�p8�p8�p8�p8�p8�p8�p8�l��%�%�%�%�N�����*�	�	�	�	���� 
�
�
����)�)�)�^$�$�$��z����D�F�F�F�F�F��r2

Zerion Mini Shell 1.0