1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
U
Þ=®dvLã @säddlmZddlZddlZddlmZddlmZddl    m
Z
ddl m Z ddl m Z dd    l mZdd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZzddlmZWn&ek
rddlm Z dZYnXej!rXddlZ"ddl#m$Z$ej%ej&e'eefZ(Gdd„de"j)ƒZ*ej+dej,dej-fdZ.d6ddddddœd d!„Z/d7dd#œd$d%ddddd&d'dd(d)œ
d*d+„Z0Gd,d-„d-ƒZ1Gd.d/„d/ƒZ2d0d1d2d3œd4d5„Z3dS)8é)Ú annotationsN)ÚBytesIO)Ú    parse_qslé)Ú
_plain_int)Ú FileStorage)ÚHeaders)Ú    MultiDict)ÚRequestEntityTooLarge)Úparse_options_header)ÚData)ÚEpilogue)ÚField)ÚFile)ÚMultipartDecoder)ÚNeedData)Úget_content_length)Úget_input_stream)ÚSpooledTemporaryFile)Ú TemporaryFile)ÚWSGIEnvironmentc@s$eZdZdddddddœdd„ZdS)    ÚTStreamFactoryNú
int | Noneú
str | Noneú t.IO[bytes]©Útotal_content_lengthÚ content_typeÚfilenameÚcontent_lengthÚreturncCsdS©N©)Úselfrrrrr"r"úJd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/formparser.pyÚ__call__'szTStreamFactory.__call__)N)Ú__name__Ú
__module__Ú __qualname__r%r"r"r"r$r&sûrÚF.)ÚboundrrrrcCsRd}tdk    r&t tjtt|dd¡S|dks6||krLt tjttdƒ¡StƒS)NiÐzrb+)Úmax_sizeÚmode)rÚtÚcastÚIOÚbytesrr)rrrrr+r"r"r$Údefault_stream_factory4s r1T©Úmax_form_partsrúTStreamFactory | Noneútype[MultiDict] | NoneÚboolÚt_parse_result)
ÚenvironÚstream_factoryÚcharsetÚerrorsÚmax_form_memory_sizeÚmax_content_lengthÚclsÚsilentr3r c    
Cst||||||||d |¡S)aÓParse the form data in the environ and return it as tuple in the form
    ``(stream, form, files)``.  You should only call this method if the
    transport method is `POST`, `PUT`, or `PATCH`.
 
    If the mimetype of the data transmitted is `multipart/form-data` the
    files multidict will be filled with `FileStorage` objects.  If the
    mimetype is unknown the input stream is wrapped and returned as first
    argument, else the stream is empty.
 
    This is a shortcut for the common usage of :class:`FormDataParser`.
 
    :param environ: the WSGI environment to be used for parsing.
    :param stream_factory: An optional callable that returns a new read and
                           writeable file descriptor.  This callable works
                           the same as :meth:`Response._get_file_stream`.
    :param max_form_memory_size: the maximum number of bytes to be accepted for
                           in-memory stored form data.  If the data
                           exceeds the value specified an
                           :exc:`~exceptions.RequestEntityTooLarge`
                           exception is raised.
    :param max_content_length: If this is provided and the transmitted data
                               is longer than this value an
                               :exc:`~exceptions.RequestEntityTooLarge`
                               exception is raised.
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    :param silent: If set to False parsing errors will not be caught.
    :param max_form_parts: The maximum number of multipart parts to be parsed. If this
        is exceeded, a :exc:`~exceptions.RequestEntityTooLarge` exception is raised.
    :return: A tuple in the form ``(stream, form, files)``.
 
    .. versionchanged:: 2.3
        Added the ``max_form_parts`` parameter.
 
    .. versionchanged:: 2.3
        The ``charset`` and ``errors`` parameters are deprecated and will be removed in
        Werkzeug 3.0.
 
    .. versionadded:: 0.5.1
       Added the ``silent`` parameter.
 
    .. versionadded:: 0.5
       Added the ``max_form_memory_size``, ``max_content_length``, and ``cls``
       parameters.
    )r9r:r;r<r=r3r?r>)ÚFormDataParserÚparse_from_environ)    r8r9r:r;r<r=r>r?r3r"r"r$Úparse_form_dataDs9ø    ÷rBc @sªeZdZUdZd$ddœddddddd    dd
d œ    d d „Zddddœdd„Zdddœdd„Zd%ddddddœdd„Zddddddœdd„Zddddddœd d!„Z    iZ
d"e d#<dS)&r@aqThis class implements parsing of form data for Werkzeug.  By itself
    it can parse multipart and url encoded form data.  It can be subclassed
    and extended but for most mimetypes it is a better idea to use the
    untouched stream and expose it as separate attributes on a request
    object.
 
    :param stream_factory: An optional callable that returns a new read and
                           writeable file descriptor.  This callable works
                           the same as :meth:`Response._get_file_stream`.
    :param max_form_memory_size: the maximum number of bytes to be accepted for
                           in-memory stored form data.  If the data
                           exceeds the value specified an
                           :exc:`~exceptions.RequestEntityTooLarge`
                           exception is raised.
    :param max_content_length: If this is provided and the transmitted data
                               is longer than this value an
                               :exc:`~exceptions.RequestEntityTooLarge`
                               exception is raised.
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    :param silent: If set to False parsing errors will not be caught.
    :param max_form_parts: The maximum number of multipart parts to be parsed. If this
        is exceeded, a :exc:`~exceptions.RequestEntityTooLarge` exception is raised.
 
    .. versionchanged:: 2.3
        The ``charset`` and ``errors`` parameters are deprecated and will be removed in
        Werkzeug 3.0.
 
    .. versionchanged:: 2.3
        The ``parse_functions`` attribute and ``get_parse_func`` methods are deprecated
        and will be removed in Werkzeug 3.0.
 
    .. versionchanged:: 2.2.3
        Added the ``max_form_parts`` parameter.
 
    .. versionadded:: 0.8
    NTr2r4rrr5r6ÚNone)    r9r:r;r<r=r>r?r3r c    Csˆ|dkr t}||_|dk    r,tjdtddnd}||_|dk    rPtjdtddnd}||_||_||_||_    |dkrxt
}||_ ||_ dS©NzJThe 'charset' parameter is deprecated and will be removed in Werkzeug 3.0.é©Ú
stacklevelúutf-8zIThe 'errors' parameter is deprecated and will be removed in Werkzeug 3.0.Úreplace) r1r9ÚwarningsÚwarnÚDeprecationWarningr:r;r<r=r3r    r>r?)    r#r9r:r;r<r=r>r?r3r"r"r$Ú__init__°s4 üüzFormDataParser.__init__Ústrzdict[str, str]zaNone | t.Callable[[FormDataParser, t.IO[bytes], str, int | None, dict[str, str]], t_parse_result])ÚmimetypeÚoptionsr cCs~tjdtdd|dkr"t|ƒjS|dkr4t|ƒjS|dkrVtjdtddt|ƒjS||jkrztjdtdd|j|SdS)    NzNThe 'get_parse_func' method is deprecated and will be removed in Werkzeug 3.0.rErFúmultipart/form-dataú!application/x-www-form-urlencodedúapplication/x-url-encodedú„The 'application/x-url-encoded' mimetype is invalid, and will not be treated as 'application/x-www-form-urlencoded' in Werkzeug 3.0.úlThe 'parse_functions' attribute is deprecated and will be removed in Werkzeug 3.0. Override 'parse' instead.)rJrKrLÚtypeÚ_parse_multipartÚ_parse_urlencodedÚparse_functions)r#rOrPr"r"r$Úget_parse_funcâs0ü
 
ü
 
ü
zFormDataParser.get_parse_funcrr7)r8r cCs:t||jd}t|ƒ}t| d¡ƒ\}}|j||||dS)zÈParses the information from the environment as form data.
 
        :param environ: the WSGI environment to be used for parsing.
        :return: A tuple in the form ``(stream, form, files)``.
        )r=Ú CONTENT_TYPE)rrOrP)rr=rr ÚgetÚparse)r#r8ÚstreamrrOrPr"r"r$rAsüz!FormDataParser.parse_from_environrzdict[str, str] | None)r^rOrrPr cCsÐ|dkr|j}nt|dkr |j}nd|dkr@tjdtdd|j}nD||jkrrtjdtdd|j| |t|ƒ¡}n|| ¡| ¡fS|dkri}z|||||ƒWSt    k
r¼|j
s¸‚YnX|| ¡| ¡fS)    a•Parses the information from the given stream, mimetype,
        content length and mimetype parameters.
 
        :param stream: an input stream
        :param mimetype: the mimetype of the data
        :param content_length: the content length of the incoming data
        :param options: optional mimetype parameters (used for
                        the multipart boundary for instance)
        :return: A tuple in the form ``(stream, form, files)``.
 
        .. versionchanged:: 2.3
            The ``application/x-url-encoded`` content type is deprecated and will not be
            treated as ``application/x-www-form-urlencoded`` in Werkzeug 3.0.
        rQrRrSrTrErFrUN) rWrXrJrKrLrYÚ__get__rVr>Ú
ValueErrorr?)r#r^rOrrPZ
parse_funcr"r"r$r]s6ü
üzFormDataParser.parsec Cs~|jdkr|jnd}|jdkr$|jnd}t|j|||j|j|jd}| dd¡ d¡}|sbt    dƒ‚| 
|||¡\}    }
||    |
fS)NrHrI)r9r:r;r<r3r>ÚboundaryÚÚasciizMissing boundary) r:r;ÚMultiPartParserr9r<r3r>r\Úencoder`r]) r#r^rOrrPr:r;ÚparserraÚformÚfilesr"r"r$rWOsúzFormDataParser._parse_multipartc
Cs€|jdk    r"|dk    r"||jkr"tƒ‚zt| ¡ ¡d|jdd}Wn*tk
rj}z tƒ|‚W5d}~XYnX|| |¡| ¡fS)NTzwerkzeug.url_quote)Úkeep_blank_valuesÚencodingr;)r<r
rÚreadÚdecoder:r`r>)r#r^rOrrPÚitemsÚer"r"r$rXhs"ÿþý
ü
z FormDataParser._parse_urlencodedzedict[str, t.Callable[[FormDataParser, t.IO[bytes], str, int | None, dict[str, str]], t_parse_result]]rY)NNNNNNT)N) r&r'r(Ú__doc__rMrZrAr]rWrXrYÚ__annotations__r"r"r"r$r@‰s&
(ø
ö"2&û7 úr@c
@speZdZdddddddddd    œd
d „Zd d dœdd„Zdd dœdd„Zddddœdd„Zdddddœdd„ZdS) rdNér4rrr5ÚintrC)r9r:r;r<r>Ú buffer_sizer3r cCs‚|dk    rtjdtddnd}||_|dk    r>tjdtddnd}||_||_||_|dkr`t}||_|dkrrt    }||_
||_ dSrD) rJrKrLr:r;r<r3r1r9r    r>rs)r#r9r:r;r<r>rsr3r"r"r$rMŒs2
üüzMultiPartParser.__init__rNz te.NoReturn)Úmessager cCs t|ƒ‚dSr!)r`)r#rtr"r"r$Úfail»szMultiPartParser.failr)Úheadersr cCs<| d¡}|r6t|ƒd}| dd¡ ¡}|dkr6|S|jS)Nú content-typerr:rb>rHrcúus-asciiú
iso-8859-1)r\r Úlowerr:)r#rvrÚ
parametersZ
ct_charsetr"r"r$Úget_part_charset¾s
 z MultiPartParser.get_part_charsetrr)Úeventrr c    CsT|j d¡}zt|jdƒ}Wnttfk
r:d}YnX|j||j||d}|S)Nrwzcontent-lengthr)rrrr)rvr\rÚKeyErrorr`r9r)r#r}rrrÚ    containerr"r"r$Ústart_file_streamingÍs 
üz$MultiPartParser.start_file_streamingr0ztuple[MultiDict, MultiDict])r^rarr c
Cs>t||j|jd}g}g}t|j|jƒD]þ}| |¡| ¡}t|t    t
fƒs(t|t ƒrh|}    g}
|
j } n¶t|t ƒrŠ|}    | ||¡}
|
j} n”t|tƒr| |jƒ|jst|    t ƒràd |
¡ | |    j¡|j¡} |  |    j| f¡n>t tjt|
¡}
|
 d¡|  |    jt|
|    j|    j|    jdf¡| ¡}q@q(|  |¡|  |¡fS)N)r<Z    max_partsór)rv)!rr<r3Ú _chunk_iterrkrsZ receive_dataZ
next_eventÚ
isinstancer rrÚappendrr€Úwriter ÚdataZ    more_dataÚjoinrlr|rvr;Únamer-r.r/r0Úseekrrr>) r#r^rarrfÚfieldsrhr†r}Z current_partrÚ_writeÚvaluer"r"r$r]ßsTý
 
 
 
 
 
 
ÿ
üþÿ zMultiPartParser.parse)NNNNNrqN)r&r'r(rMrur|r€r]r"r"r"r$rd‹sø/rdzt.Callable[[int], bytes]rrzt.Iterator[bytes | None])rkÚsizer ccs ||ƒ}|sq|VqdVdS)zŠRead data in chunks for multipart/form-data parsing. Stop if no data is read.
    Yield ``None`` at the end to signal end of parsing.
    Nr")rkrr†r"r"r$r‚s
r‚)N)NNNNNNT)4Ú
__future__rÚtypingr-rJÚiorÚ urllib.parserÚ    _internalrZdatastructuresrrr    Ú
exceptionsr
Úhttpr Zsansio.multipartr r rrrrZwsgirrÚtempfilerÚ ImportErrorrÚ TYPE_CHECKINGÚteZ_typeshed.wsgirÚTupler/r0r7ÚProtocolrÚTypeVarÚCallableÚAnyr)r1rBr@rdr‚r"r"r"r$Ú<module>s^                  
  üø
ö$E