Your IP : 18.118.28.160


Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/cgi.cpython-312.opt-1.pyc

�

�Q�f�����dZdZddlmZmZmZddlmZddlZddl	Z	ddl
Zddlm
Z
ddlmZddlZddlZddlZddlZgd�Zej*ed	�
�dadad�Zd
�Zd�Zd�Zeadade	j>dddfd�Z d"d�Z!d�Z"d�Z#Gd�d�Z$Gd�d�Z%e	j>fd�Z&d#d�Z'e	j>fd�Z(d�Z)d�Z*d�Z+d�Z,d �Z-ed!k(re&�yy)$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��trts	ttdd��atstantat|�y#t$rY�'wxYw)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/python312/lib64/python3.12/cgi.py�initlogr,AsZ��0
�M�M�K�$��4��u�	���#��9�E��������M��
�	��	�s�A�	A$�#A$c�:�tj||zdz�y)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��y)z9Dummy function, assigned to log when logging is disabled.N�r)s r+r&r&js��r2c�L�datrtj�datay)zClose the log file.rN)r"r#�closer,r'r4r2r+�closelogr7ns���G��
���
���
�Cr2�&c���|�tj}t|d�r
|j}nd}t	|t
�r|j}d|vrd|d<|ddk(r�t|d�\}}|dk(rt|||�	�S|d
k(rIt|d�}tr|tkDrtd��|j|�j|�}	nd
}	d|vr|	r|	dz}	|	|dz}	n0tjddr|	r|	dz}	|	tjdz}	|	|d<n8d|vr|d}	n.tjddrtjd}	nd
}	|	|d<tj j#|	||||��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�Y���r�*���;�;�����"�m�$�
�Y�Y���w�&�$)�� �!��� �F�*�#�G�N�$;�<���u��)�)�"�2�u�	�B�B�
�9�
9��'�"2�3�4�G��'�F�*� �!B�C�C�����!�(�(��2�B��B��W�$���S��2��g�n�-�-�B�
�X�X�a�b�\���S��2��c�h�h�q�k�!�B�"$����	�7�	"�
�^�
$���8�8�A�B�<����!��B��B�"$�����<�<� � ��%6��*2�i�!�I�Ir2c�"�|djd�}dj|�}t�}|j|�	|d|d<t||||ddi|��}|D�	cic]}	|	|j
|	���c}	S#t$rY�>wxYwcc}	w)	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>)rM�formatr�set_type�KeyErrorr
�getlist)
rQrVrr]r>rZrUr\�fs�ks
          r+rr�s����Z� �'�'��0�H�.�5�5�h�?�E��i�G����U��
�$)�*:�$;�� �!�
�b�'�H�V�!�6�*�i�
A�B�&(�)�b��A�r�z�z�!�}��b�)�)��	�
��
��*s�A=�!B�=	B	�B	c#�K�|dddk(r�|dd}|jd�}|dkDro|jdd|�|jdd|�z
dzrE|jd|dz�}|dkDr+|jdd|�|jdd|�z
dzr�E|dkrt|�}|d|}|j���||d}|dddk(r��yy�w)NrC�;r�"�\"r)�find�count�len�strip)�s�end�fs   r+�_parseparamro�s�����
�B�Q�%�3�,�
�a�b�E���f�f�S�k���A�g�1�7�7�3��3�/�!�'�'�%��C�2H�H�A�M��&�&��c�A�g�&�C��A�g�1�7�7�3��3�/�!�'�'�%��C�2H�H�A�M���7��a�&�C�
�d�s�G���g�g�i��
�c�d�G���B�Q�%�3�,�s�BC�4C�
Cc��td|z�}|j�}i}|D]�}|jd�}|dk\s�|d|j�j	�}||dzdj�}t|�dk\r;|d|dcxk(rdk(r*nn'|dd}|j
d	d
�j
dd�}|||<��||fS)zfParse a Content-type like header.

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

    re�=rNrCr���rfz\\�\rg)ro�__next__rhrk�lowerrj�replace)�line�parts�keyrV�p�i�name�values        r+r
r
�s���
��d�
�#�E�
�.�.�
�C��E�
��
�F�F�3�K����6��R�a�5�;�;�=�&�&�(�D��a��c�d�G�M�M�O�E��5�z�Q��5��8�u�R�y�#?�C�#?��a�����
�
�f�d�3�;�;�E�3�G���E�$�K����:�r2c�<�eZdZdZdZdZdZdZiZdZ	iZ
iZd�Zd�Z
y)r	z=Like FieldStorage, for use when no file uploads are possible.Nc� �||_||_y)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��
�
�C�Cr2)�__name__�
__module__�__qualname__�__doc__�filename�list�type�file�type_options�disposition�disposition_optionsr\r�r�r4r2r+r	r	s;��G��H��D��D��D��L��K����G��Dr2r	c���eZdZdZdddej
dddddddfd�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 y)#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.

    Nr2r�utf-8rvr8c�6�d}||_||_|
|_||_d|vr|dj	�}d|_|dk(s|dk(rhd|vr|d}
n)tjddrtjd}
nd}
|
jtj�d�}
t|
�}|�d	d
i}|�3i}|dk(rd
|d	<d|vr|d|d	<d|vr
|d|_d
|vr*|d
|d<n!t|ttf�std��||_|� tj"j$|_nLt|t(�r|j$|_n*t+|d�rt+|d�std��||_||_|	|_t|t0�s!tdt3|�j4z��||_d|_||_di}}d|j vrt=|j d�\}}||_||_ d|_!d|vr
|d|_!d|_"d|vr
|d|_"|jDdu|_#d	|j vrt=|j d	�\}}n|j6s|dk7rdi}}nd
i}}||_||_$d|vr/|dj|j,|j.�|_%nd|_%d}d|j vr3	tM|j d�}tPr|tPkDrtOd��||_)|j:�|dk\r||_dx|_*|_+d|_,|d
k(r|j[�y|dddk(r|j]|||�y|j_�y#tN$rY��wxYw)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/plainrZr2rrrA�
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�F�����U�?�f��.���(��^�,�����!�"���X�X�a�[�������6�6�6�8�:K�L�B����B���)�>�@���?��G����*M���'���(�*1�.�*A���'���(�")�.�"9����7�*�,3�4D�,E��(�)��w��'�(:�;��!8�9�9����
�:��i�i�&�&�D�G�
��M�
*��i�i�D�G��B��'�G�B�
�,C�� 9�:�:��D�G� ��
�����-��/��A�"�=�1�:�:�;�<�
<�*��������
��2�u�� �D�L�L�0�'����5J�(K�L�L�E�5� ���#(�� ���	��U�?��f�
�D�I���
����!�*�-�D�M� �M�M��5����T�\�\�)�'����^�(D�E�L�E�5�
�
�
�6�V�#3�'��5�E�>��5�E���	�!������!&�z�!2�!9�!9�$�-�-�:>�+�+�"G�D��"%�D�����t�|�|�+�
��4�<�<�(8�9�:���$��-� �!B�C�C�����:�:��$�!�)��D�J� $�$��	�D�I���	��7�7�� � �"�
�3�B�Z�<�
'��O�O�G�%6��G�������
��
�s�#N�	N�Nc�X�	|jj�y#t$rYywxYw�N)r�r6�AttributeErrorr�s r+�__del__zFieldStorage.__del__�s'��	��I�I�O�O����	��	�s��	)�)c��|Sr�r4r�s r+�	__enter__zFieldStorage.__enter__�s���r2c�8�|jj�yr�)r�r6)r�r1s  r+�__exit__zFieldStorage.__exit__�s���	�	���r2c�V�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�4�t|j��Sr�)�iter�keysr�s r+�__iter__zFieldStorage.__iter__s���D�I�I�K� � r2c��|dk7rt|��|jrR|jjd�|jj�}|jjd�|S|j�|j}|Sd}|S)Nr}r)r�r��seekrLr�r�s   r+�__getattr__zFieldStorage.__getattr__sz���7�?� ��&�&��9�9��I�I�N�N�1���I�I�N�N�$�E��I�I�N�N�1��
��	�Y�Y�
"��I�I�E����E��r2c���|j�td��g}|jD]#}|j|k(s�|j|��%|st	|��t|�dk(r|dS|S)zDictionary style indexing.�
not indexablerCr)r�r�r|�appendr`rj)r�ry�found�items    r+�__getitem__zFieldStorage.__getitem__sg���9�9���O�,�,����I�I�D��y�y�C�����d�!3����3�-���u�:��?���8�O��Lr2c��||vr;||}t|t�r|D�cgc]}|j��c}S|jS|Scc}w)z8Dictionary style get() method, including 'value' lookup.�rGr�r})r�ry�defaultr}�xs     r+�getvaluezFieldStorage.getvaluesI���$�;���I�E��%��&�).�/��A�����/�/��{�{�"��N��	0s�Ac�n�||vr0||}t|t�r|djS|jS|S)z! Return the first value received.rr�)r�ryr�r}s    r+�getfirstzFieldStorage.getfirst)s9���$�;���I�E��%��&��Q�x�~�~�%��{�{�"��Nr2c��||vr<||}t|t�r|D�cgc]}|j��c}S|jgSgScc}w)z  Return list of received values.r�)r�ryr}r�s    r+razFieldStorage.getlist4sK���$�;���I�E��%��&�).�/��A�����/�/����}�$��I��	0s�Ac�z�|j�td��ttd�|jD���S)zDictionary style keys() method.r�c3�4K�|]}|j���y�wr��r|)�.0r�s  r+�	<genexpr>z$FieldStorage.keys.<locals>.<genexpr>Cs����8�i�d��	�	�i�s�)r�r��setr�s r+r�zFieldStorage.keys?s1���9�9���O�,�,��C�8�d�i�i�8�8�9�9r2c�n��|j�td��t�fd�|jD��S)z%Dictionary style __contains__ method.r�c3�<�K�|]}|j�k(���y�wr�r�)r�r�rys  �r+r�z,FieldStorage.__contains__.<locals>.<genexpr>Is�����:�	��4�9�9��#�	�s�)r�r��any)r�rys `r+�__contains__zFieldStorage.__contains__Es-����9�9���O�,�,��:��	�	�:�:�:r2c�4�t|j��S)z Dictionary style len(x) support.)rjr�r�s r+�__len__zFieldStorage.__len__Ks���4�9�9�;��r2c�Z�|j�td��t|j�S)NzCannot be converted to bool.)r�r��boolr�s r+�__bool__zFieldStorage.__bool__Os&���9�9���:�;�;��D�I�I��r2c	��|jj|j�}t|t�s-t|j�dt
|�j����|j|j|j�}|jr|d|jzz
}tjj||j|j |j|j|j"|j$��}|D��cgc]\}}t'||���c}}|_|j+�ycc}}w)z+Internal: read data in query string format.� should return bytes, got r8�rr]r�r>N)rQrLr�rGr�rKr�r�rMrr]r�rOr�	parse_qslrSrTr�r>r	r��
skip_lines)r�rX�queryryr}s     r+r�zFieldStorage.read_urlencodedTs���
�W�W�\�\�$�+�+�
&���"�e�$�� $����b��):�):�<�=�
=�
�Y�Y�t�}�}�d�k�k�
2���?�?��#����'�'�B����&�&���&�&��(;�(;��]�]�4�;�;��.�.�$�.�.�'�J��EJ�J�E�j�c�5�%�c�5�1�E�J��	������Ks�D>c
�|�|j}t|�std|����g|_|jr�t
jj|j|j|j|j|j|j|j��}|jjd�|D��|jxs|j }|j"j%�}t'|t(�s-t|j"�dt+|�j,����|xj.t1|�z
c_|j3�d|jzk7r]|r[|j"j%�}|xj.t1|�z
c_|j3�d|jzk7r|r�[|j}|�|t1|j�z}	t5�}	d}
	|j"j%�}|
|z
}
|j3�sn�1|
s�nq|xj.t1|
�z
c_|	j7|
j9|j|j��|	j;�}d|vr|d=|j<�dn|j<|j.z
}
||j"||||||
|j|j||j�}|�9|d	z}|jr|t1|j�z}|d
krtd��|xj.|j.z
c_|jj?|�|j@s"|j.|jBcxk\rd
kDrnnn���|jE�y)z/Internal: read a part that is itself multipart.z$Invalid boundary in multipart form: r�c3�:K�|]\}}t||����y�wr�)r	)r�ryr}s   r+r�z*FieldStorage.read_multi.<locals>.<genexpr>qs����R�E�j�c�5�-�c�5�9�E�s�r��--Nr2r�rCrzMax number of fields exceeded)#r��valid_boundaryrKr�r�rOrr�rSrTrr]r�r>�extend�FieldStorageClass�	__class__rQr�rGr�r�r�r�rjrkr�feedrMr6r�r�r�r�r�)r�rRrSrT�ibr��klass�
first_liner��parser�hdr_text�datar\r��parts               r+r�zFieldStorage.read_multifs
��
�
�
���b�!���M�N�N���	��?�?��L�L�*�*�����!7�!7��9L�9L����t�{�{�#�2�2�d�n�n�+�N�E�
�I�I���R�E�R�R��&�&�8�$�.�.���W�W�%�%�'�
��*�e�,�� $����j�)9�)B�)B�D�E�
E����3�z�?�*�����!�e�d�.@�.@�&@�A�����)�)�+�J��O�O�s�:��.�O����!�e�d�.@�.@�&@�A��
�,�,���%��c�$�)�)�n�,�N���\�F��H���w�w�'�'�)���D� ���z�z�|��	�
���O�O�s�8�}�,�O��K�K�����
�
�t�{�{�C�D��l�l�n�G� �7�*��,�-� �J�J�.�D��Z�Z�$�/�/�1�
�����'�2�w�8I�'��������^�T�^�^�U�D��)��!�#���9�9�"�c�$�)�)�n�4�N�!�A�%�$�%D�E�E��O�O�t���.�O��I�I���T�"��y�y�D�O�O�t�{�{�>�Q�>��G�H	
���r2c��|jdk\r!|j�|j�n|j�|jjd�y)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�|_|j}|dk\r�|dkDr�|jj	t||j��}t|t�s-t|j�dt|�j����|xjt|�z
c_|sd|_y|jj|�|t|�z
}|dkDr��yyy)zInternal: read binary data.rr�rrN)�	make_filer�r�rQrL�min�bufsizerGr�rKr�r�r�rjr�r/)r��todor�s   r+r�zFieldStorage.read_binary�s����N�N�$��	��{�{���1�9���(��w�w�|�|�C��d�l�l�$;�<��!�$��.�$�(,����d��1D�1D�&F�G�G����3�t�9�,��� "�D�I���	�	����%��c�$�i�'����(�r2c���|jrt�x|_|_nt	�x|_|_|j
r|j
�y|j�y)z0Internal: read lines until EOF or outerboundary.N)r�rr��_FieldStorage__filerr��read_lines_to_outerboundary�read_lines_to_eofr�s r+r�zFieldStorage.read_lines�sL�����&-�i�/�D�I���&.�j�0�D�I�������,�,�.��"�"�$r2c���|j�z|jj�t|�zdkDrQ|j�|_|jj�}|jj
|�d|_|jr|jj
|�y|jj
|j|j|j��y)z line is always bytes, not stringNi�)r��tellrjr�r�r�r/r�rMrr])r�rwr�s   r+�__writezFieldStorage.__write�s����;�;�"��{�{���!�C��I�-��4� �N�N�,��	��{�{�+�+�-���	�	����%�"�������I�I�O�O�D�!�
�I�I�O�O�D�K�K��
�
�t�{�{�C�Dr2c��	|jjd�}|xjt|�z
c_|sd|_y|j|��U)zInternal: read lines until EOF.�rrN)rQr�r�rjr��_FieldStorage__write)r�rws  r+r�zFieldStorage.read_lines_to_eof�sI����7�7�#�#�E�*�D��O�O�s�4�y�(�O����	���L�L���
r2c�~�d|jz}|dz}d}d}d}	|j�d|jcxkr|kry|jjd�}|xjt|�z
c_|t|�z
}|sd|_y|d	k(r||z}d}|jd�r%|r#|j�}||k(ry||k(rd|_y|}|jd
�r
d
}|dd}d}n:|jd�r
d}|dd}d}n|jd	�r
d	}|dd}d
}nd}d
}|j||z���#)z�Internal: read lines until outerboundary.
        Data is read as bytes: boundaries and line ends must be converted
        to bytes for comparisons.
        r�r2TrrCNrrr�
s
����
F)r�r�rQr�r�rjr��
startswith�rstrip�endswithr)	r��
next_boundary�
last_boundary�delim�last_line_lfend�_readrw�strippedline�odelims	         r+r�z(FieldStorage.read_lines_to_outerboundary�si��
�� 2� 2�2�
�%��-�
���������z�z�%�!�t�z�z�*B�U�*B��+C��7�7�#�#�E�*�D��O�O�s�4�y�(�O��S��Y��E����	����~��t�|�������u�%�/�#�{�{�}���=�0���=�0� !�D�I���F��}�}�W�%����C�R�y��"&�����u�%����C�R�y��"&�����u�%����C�R�y��"'����"'���L�L��$��'�Mr2c�x�|jr|jryd|jz}|dz}d}	|jjd�}|xjt|�z
c_|sd|_y|j
d�r%|r#|j�}||k(ry||k(rd|_y|j
d�}��)z5Internal: skip lines until outer boundary if defined.Nr�TrrrrCr)r�r�rQr�r�rjr
rk)r�rrrrwrs      r+r�zFieldStorage.skip_liness����!�!�T�Y�Y���� 2� 2�2�
�%��-�
�����7�7�#�#�E�*�D��O�O�s�4�y�(�O����	���}�}�U�#��#�z�z�|���=�0���=�0� !�D�I��"�m�m�E�2�O�r2c��|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+r�zFieldStorage.make_file3s<��0����)�)�%�0�0��)�)�$����$�8�
8r2r�)!r�r�r�r��osrRr�r�r�r�r�r�r�r�r�r�rar�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r4r2r+r
r
s���(�R��C����q���g�i� $��c�J���6�
!���	�	�	�:�;� ��
� ��C�J��G�(�"	%�
E��0(�d3�,8r2r
c���td�t�tjt_	t	�}t�t
�t|�t|�t�d�}|fd�}td�|�td�da	t	�}t�t
�t|�t|�y#t�Y�QxYw#t�YyxYw)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�y)Nz,testing print_exception() -- <I>italics?</I>)�execr4r2r+rnztest.<locals>.ffs���?�@r2c��|�yr�r4)rns r+�gztest.<locals>.ghs��
�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�formrnrs    r+rrUs���
�
#�$�	�G����C�J���~�������4���g����	A��	�
�I�J�	��
�
6�7��F���~�������4���g����������s�AC�4C�C�C*c
�P�|�tj�\}}}ddl}t�td�|j	||�|j||�z}tdt
jdj|dd���dt
j|d��d��~y)Nrz+<H3>Traceback (most recent call last):</H3>z<PRE>rrrz<B>z
</B></PRE>)	rD�exc_info�	tracebackr�	format_tb�format_exception_only�html�escape�join)r�r}�tbr�r$r�s      r+rr|s����|��,�,�.���e�R��	�G�	�
7�8����r�5�)��*�*�4��7�8�D�	����B�G�G�D��"�I�&�'����D��H��
��	r2c
��t|j��}t�td�td�|D]9}tdtj|�dtj||���;td�t�y)z#Dump the shell environment as HTML.z<H3>Shell Environment:</H3>�<DL>�<DT>�<DD>�</DL>N)�sortedr�rr'r()rRr�rys   r+rr�sa���'�,�,�.�!�D�	�G�	�
'�(�	�&�M���
�f�d�k�k�#�&�����G�C�L�0I�J��	�'�N�	�Gr2c���t|j��}t�td�|std�td�|D]�}tdtj|�zdzd��||}tdtjtt
|���zd	z�td
tjt|��z���td�t�y)
z$Dump the contents of a form as HTML.z<H3>Form Contents:</H3>z<P>No form fields.r,r-�:� )rmz<i>z</i>r.r/N)r0r�rr'r(�reprr�)r!r�ryr}s    r+rr�s����$�)�)�+��D�	�G�	�
#�$��
�"�#�	�&�M���
�f�t�{�{�3�'�'�#�-�3�7��S�	��
�e�d�k�k�$�t�E�{�"3�4�4�v�=�>�
�f�t�{�{�4��;�/�/�0�	�

�'�N�	�Gr2c	�8�t�td�	tj�}ttj|��t�y#t
$r<}tdtjt
|���Yd}~t�yd}~wwxYw)z#Dump the current directory as HTML.z#<H3>Current Working Directory:</H3>zOSError:N)rr�getcwdr'r(r%�str)�pwd�msgs  r+rr�sk��	�G�	�
/�0� ��i�i�k��	�d�k�k�#���	�G��	�1�
�j�$�+�+�c�#�h�/�0�0�
�G��	1�s�A�	B�(B�Bc��t�td�t�ttj�t�y)Nz <H3>Command Line Arguments:</H3>)rrDrNr4r2r+rr�s%��	�G�	�
,�-�	�G�	�#�(�(�O�	�Gr2c��td�y)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)rr4r2r+rr�s��	�'�'r2c�X�ddl}t|t�rd}nd}|j||�S)Nrs^[ -~]{0,200}[!-~]$z^[ -~]{0,200}[!-~]$)�rerGr��match)rlr=�_vb_patterns   r+r�r��s*��
��!�U��,��+��
�8�8�K��#�#r2�__main__)r�rvr8)NNNN).r��__version__�iorrr�collections.abcrrDr�urllib.parserO�email.parserr�
email.messagerr'rrr�__all__�_deprecatedr�r"r#r,r(r&r7r'rJrRrrror
r	r
rrrrrrrr�r4r2r+�<module>rIs��	�*��0�/�#�
�	��#�!��
���"������X�f�-�

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

?>