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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
U
Þ=®ds²ã
@sÒUdZddlmZddlZddlZddlZddlZddlZddl    m
Z
ddl    m Z ddl    m Z ddl    m Z ddl    mZd    d
lmZd    d lmZd    d lmZd    d lmZd    dlmZejrÄd    dlmZe d¡ZdZee d¡ƒZdZdd„eDƒZ dd„e!dƒDƒZ"Gdd„dej#ƒZ$Gdd„de$ƒZ%Gdd„de%ƒZ&Gdd „d e%ƒZ'eƒe iZ(d!e)d"<dšd$d$d%d&œd'd(„Z*d)d*d+d,d-d.œd/d0„Z+d›d*d*d*d1œd2d3„Z,dœd*d5d+dd6œd7d8„Z-dd*d*d$d$d<d=œd>d?„Z.e.ƒZ/e.d@dAdBZ0d%d*dCœdDdE„Z1džd$d*d*d$d$d*dFœdGdH„Z2dŸd*d*d*d*d*dIœdJdK„Z3dLd*dMœdNdO„Z4d d$d*d*d*d*dQœdRdS„Z5d¡d$d*d*d*dTœdUdV„Z6d¢d*d*d*dWœdXdY„Z7dZd[d\œd]d^„Z8e 9d_e8¡d*d*d`daœdbdc„Z:e;e!ddƒd£˜ƒ <¡Z=e:dge=ƒZ>e:dhe=diƒZ?e:dje=dkƒZ@e:dle=dmƒZAd¤dnd5d5d*doœdpdq„ZBd¥dnd5d5drd*dsœdtdu„ZCd*d*dvœdwdx„ZDd¦dzd*d+d*d*d{d|d}œd~d„ZEd§dd*d+d*d%d{d‚d|dƒœd„d…„ZFd†d*d+d*d‡dˆœd‰dŠ„ZGd¨d)d*d+d,d*d*dŒœddŽ„ZHd©d)dd*d+d,d*dd‘œd’d“„ZIdªdndnd+d*d”œd•d–„ZJd«d)d*d*d—œd˜d™„ZKdS)¬z€Functions for working with URLs.
 
Contains implementations of functions from :mod:`urllib.parse` that
handle bytes and strings.
é)Ú annotationsN)Úquote)Úunquote)Ú    urlencode)Úurlsplit)Ú
urlunsplité)Ú_check_str_tuple)Ú _decode_idna)Ú_make_encode_wrapper)Ú_to_str©Úiter_multi_items)Údatastructuresz^[a-zA-Z0-9+-.]+$zKabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~$!'()*+,;ÚasciiÚ0123456789ABCDEFabcdefcCs8i|]0}tD]&}|›|› d¡t|›|›dƒ“q qS)ré)Ú
_hexdigitsÚencodeÚint)Ú.0ÚaÚb©rúDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/urls.pyÚ
<dictcomp>*s
þrcCsg|]}d|d› d¡‘qS)ú%Ú02Xr)r)rÚcharrrrÚ
<listcomp>/sréc@s6eZdZUded<ded<ded<ded<ded<dS)Ú    _URLTupleÚstrÚschemeÚnetlocÚpathÚqueryÚfragmentN)Ú__name__Ú
__module__Ú __qualname__Ú__annotations__rrrrr!2s
 
r!cs¤eZdZUdZdZded<ded<ded<ded<dddd    œ‡fd
d „ Zdd œd d„Zdddœdd„Ze    dd œdd„ƒZ
e    dd œdd„ƒZ e    dd œdd„ƒZ e    dd œdd„ƒZ e    dd œdd„ƒZe    dd œdd„ƒZe    dd œd d!„ƒZe    dd œd"d#„ƒZddd$d    œd%d&„Zdddd    œd'd(„Zdd œd)d*„Zdd œd+d,„Zdd œd-d.„Zdd œd/d0„Zdd œd1d2„Zd?dd4d5œd6d7„Zd8d œd9d:„Zd4d œd;d<„Zd4d œd=d>„Z‡ZS)@ÚBaseURLz¨Superclass of :py:class:`URL` and :py:class:`BytesURL`.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    rr"Ú_atÚ_colonÚ    _lbracketÚ    _rbracketzt.Any)ÚargsÚkwargsÚreturncs.tjd|j›dtddtƒj|f|ž|ŽS)Nz'werkzeug.urls.z\' is deprecated and will be removed in Werkzeug 3.0. Use the 'urllib.parse' library instead.é©Ú
stacklevel)ÚwarningsÚwarnr(ÚDeprecationWarningÚsuperÚ__new__)Úclsr1r2©Ú    __class__rrr;Gs  üzBaseURL.__new__©r3cCs| ¡S©N)Úto_url©ÚselfrrrÚ__str__PszBaseURL.__str__)r2r3cKs |jf|ŽS)z†Return an URL with the same values, except for those parameters
        given new values by whichever keyword arguments are specified.)Ú_replace)rCr2rrrÚreplaceSszBaseURL.replaceú
str | NonecCs | ¡dS)z¹The host part of the URL if available, otherwise `None`.  The
        host is either the hostname or the IP address mentioned in the
        URL.  It will not contain the port.
        r)Ú _split_hostrBrrrÚhostXsz BaseURL.hostcCsF|j}|dk    rBt|tƒrBz| d¡ d¡}Wntk
r@YnX|S)a Works exactly like :attr:`host` but will return a result that
        is restricted to ASCII.  If it finds a netloc that is not ASCII
        it will attempt to idna decode it.  This is useful for socket
        operations when the URL might include internationalized characters.
        NÚidnar)rIÚ
isinstancer"rÚdecodeÚ UnicodeError©rCÚrvrrrÚ
ascii_host`szBaseURL.ascii_hostú
int | Nonec    CsTz6tt| ¡dƒƒ}d|kr*dkr4nn|WSWnttfk
rNYnXdS)z}The port in the URL as an integer if it was present, `None`
        otherwise.  This does not fill in default ports.
        rriÿÿN)rr rHÚ
ValueErrorÚ    TypeErrorrNrrrÚportos
z BaseURL.portcCs | ¡dS)zSThe authentication part in the URL if available, `None`
        otherwise.
        r)Ú _split_netlocrBrrrÚauth|sz BaseURL.authcCs | ¡d}|dk    rt|ƒSdS)zƒThe username if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a string.
        rN©Ú _split_authÚ_url_unquote_legacyrNrrrÚusernameƒs zBaseURL.usernamecCs | ¡dS)zThe username if it was part of the URL, `None` otherwise.
        Unlike :attr:`username` this one is not being decoded.
        r©rXrBrrrÚ raw_usernameszBaseURL.raw_usernamecCs | ¡d}|dk    rt|ƒSdS)zƒThe password if it was part of the URL, `None` otherwise.
        This undergoes URL decoding and will always be a string.
        rNrWrNrrrÚpassword”s zBaseURL.passwordcCs | ¡dS)zThe password if it was part of the URL, `None` otherwise.
        Unlike :attr:`password` this one is not being decoded.
        rr[rBrrrÚ raw_passwordžszBaseURL.raw_passwordúds.MultiDict[str, str]cOst|jf|ž|ŽS)zØDecodes the query part of the URL.  Ths is a shortcut for
        calling :func:`url_decode` on the query argument.  The arguments and
        keyword arguments are forwarded to :func:`url_decode` unchanged.
        )Ú
url_decoder&©rCr1r2rrrÚ decode_query¥szBaseURL.decode_querycOstt|f|ž|ŽƒS)z©Joins this URL with another one.  This is just a convenience
        function for calling into :meth:`url_join` and then parsing the
        return value again.
        )Ú    url_parseÚurl_joinrarrrÚjoin¬sz BaseURL.joincCst|ƒS)zºReturns a URL string or bytes depending on the type of the
        information stored.  This is just a convenience function
        for calling :meth:`url_unparse` for this URL.
        )Ú url_unparserBrrrrA³szBaseURL.to_urlc
Cs„|jpd}d|krd|›d}|j}|dk    r:|›d|›}d tdt|jpLddddƒt|jp^ddddƒgƒ¡}|r€|›d    |›}|S)
z6Encodes the netloc part to an ASCII safe URL as bytes.Úú:ú[ú]Núutf-8Ústrictz/:%ú@)rPrTreÚfilterÚ    url_quoter\r^)rCrOrTrVrrrÚ encode_netlocºs"
 þþÿ    zBaseURL.encode_netloccCs–|jpd}t|tƒr| ¡}t|ƒ}d|kr8d|›d}|j}|dk    rT|›d|›}d tdt|j    pfddƒt|j
ptddƒgƒ¡}|r’|›d|›}|S)z&Decodes the netloc part into a string.rgrhrirjNz/:%@rm) rIrKÚbytesrLr
rTrernrYr\r^)rCrIrOrTrVrrrÚ decode_netlocÏs(
 
 þþÿ    zBaseURL.decode_netloccCs tt|ƒƒS)a*Returns a :class:`BytesURL` tuple that holds a URI.  This will
        encode all the information in the URL properly to ASCII using the
        rules a web browser would follow.
 
        It's usually more interesting to directly call :meth:`iri_to_uri` which
        will return a string.
        )rcÚ
iri_to_urirBrrrÚ to_uri_tupleêszBaseURL.to_uri_tuplecCs tt|ƒƒS)aSReturns a :class:`URL` tuple that holds a IRI.  This will try
        to decode as much information as possible in the URL without
        losing information similar to how a web browser does it for the
        URL bar.
 
        It's usually more interesting to directly call :meth:`uri_to_iri` which
        will return a string.
        )rcÚ
uri_to_irirBrrrÚ to_iri_tupleôs    zBaseURL.to_iri_tupleNztuple[str | None, str | None])Ú
pathformatr3cCs:|jdkrdSt|jƒ}|jp d}|dkr>tjdkr:d}nd}|dkrø|dd…dkr”|dd    … ¡r”|d    d
…d kr”|dd    …›d |d
d…›}|dd
…d k}ddl}| |¡}|rö|dkrö|     d¡ 
dd¡}t |ƒd    krê|\}}n |d}d}n,|dkrddl }| |¡}nt d|›ƒ‚|dkr2d}||fS)a@Returns a tuple with the location of the file in the form
        ``(server, location)``.  If the netloc is empty in the URL or
        points to localhost, it's represented as ``None``.
 
        The `pathformat` by default is autodetection but needs to be set
        when working with URLs of a specific system.  The supported values
        are ``'windows'`` when working with Windows or DOS paths and
        ``'posix'`` when working with posix paths.
 
        If the URL does not point to a local file, the server and location
        are both represented as ``None``.
 
        :param pathformat: The expected format of the path component.
                           Currently ``'windows'`` and ``'posix'`` are
                           supported.  Defaults to ``None`` which is
                           autodetect.
        Úfile©NNNÚntZwindowsÚposixrú/r4éz|:rh)z\\\z///rú\rgzInvalid path format )z    127.0.0.1z::1Ú    localhost)r#Ú url_unquoter%r$ÚosÚnameÚisalphaÚntpathÚnormpathÚlstripÚsplitÚlenÚ    posixpathrS)rCrwr%rIZ windows_sharer„Úpartsr‰rrrÚget_file_locationÿs6
 
 
 
0
 
 
 
zBaseURL.get_file_locationztuple[str | None, str]cCs2|j|jkr(|j |j¡\}}}||fSd|jfSr@)r-r$Ú    partition)rCrVÚ_r$rrrrU=s zBaseURL._split_netloccCs@| ¡d}|sdS|j|kr&|dfS| |j¡\}}}||fS)Nrry)rUr.rŒ)rCrVrZrr]rrrrXCs 
zBaseURL._split_authcCs¨| ¡d}|sdS| |j¡sL|j|krD| |j¡\}}}||fS|dfS| |j¡}|dkrh|dfS|d|…}||dd…}| |j¡r ||dd…fS|dfS)Nrryr)rUÚ
startswithr/r.rŒÚfindr0)rCrOrIrrTÚidxÚrestrrrrHMs   
   zBaseURL._split_host)N)r(r)r*Ú__doc__Ú    __slots__r+r;rDrFÚpropertyrIrPrTrVrZr\r]r^rbrerArprrrtrvr‹rUrXrHÚ __classcell__rrr=rr,:sJ
             
 ÿ>
r,c@s8eZdZdZdZdZdZdZdZdd    d    d
d œd d „Z    dS)ÚURLzÿRepresents a parsed URL.  This behaves like a regular tuple but
    also has some extra attributes that give further insight into the
    URL.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    rrmrhrirjrkrFr"ÚBytesURL©ÚcharsetÚerrorsr3c    Cs:t|j d¡| ¡|j ||¡|j ||¡|j ||¡ƒS)z€Encodes the URL to a tuple made out of bytes.  The charset is
        only being used for the path, query and fragment.
        r)r—r#rrpr%r&r'©rCr™ršrrrrrs
   ûz
URL.encodeN)rkrF)
r(r)r*r’r“r-r.r/r0rrrrrr–csr–c@sTeZdZdZdZdZdZdZdZddœd    d
„Z    d dœd d „Z
dddddœdd„Z dS)r—z’Represents a parsed URL in bytes.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use the ``urllib.parse`` library instead.
    ró@ó:ó[ó]r"r?cCs| ¡ dd¡S)NrkrF)rArLrBrrrrDŒszBytesURL.__str__rqcCs|jS)z&Returns the netloc unchanged as bytes.)r$rBrrrrpszBytesURL.encode_netlocrkrFr–r˜c    Cs:t|j d¡| ¡|j ||¡|j ||¡|j ||¡ƒS)z‚Decodes the URL to a tuple made out of strings.  The charset is
        only being used for the path, query and fragment.
        r)r–r#rLrrr%r&r'r›rrrrL“s
   ûzBytesURL.decodeN)rkrF) r(r)r*r’r“r-r.r/r0rDrprLrrrrr—sr—z&dict[frozenset[int], dict[bytes, int]]Ú _unquote_mapsrgz str | bytesrq)ÚstringÚunsafer3csìt|tƒr| d¡}tˆtƒr(ˆ d¡‰ttˆƒƒ‰t| d¡ƒ}tt|dƒƒ}z tˆ}Wn2t    k
rއfdd„t
  ¡Dƒ}tˆ<YnX|D]N}|dd…}||krÎ|  ||¡|  |dd…¡q”|  d¡|  |¡q”t|ƒS)Nrkó%ócsi|]\}}|ˆkr||“qSrr)rÚhr©r¢rrr±sz%_unquote_to_bytes.<locals>.<dictcomp>r4é%)rKr"rÚ    frozensetÚ    bytearrayÚiterr‡Únextr ÚKeyErrorÚ
_hextobyteÚitemsÚappendÚextendrq)r¡r¢ÚgroupsÚresultZ hex_to_byteÚgroupÚcoderr¦rÚ_unquote_to_bytes£s*
 
 
 
 
ÿ 
 rµz1t.Mapping[str, str] | t.Iterable[tuple[str, str]]r"Úboolz+t.Callable[[tuple[str, str]], t.Any] | Nonezt.Iterator[str])Úobjr™ÚsortÚkeyr3c
cs”ddlm}||ƒ}|r$t||d}|D]f\}}|dkr:q(t|tƒsTt|ƒ |¡}n|}t|tƒsrt|ƒ |¡}    n|}    t|ƒ›dt|    ƒ›Vq(dS)Nrr )r¹ú=)rrÚsortedrKrqr"rÚ_fast_url_quote_plus)
r·r™r¸r¹rÚiterableZkey_strZ    value_strÚ    key_bytesZ value_bytesrrrÚ_url_encode_implÂs   
 
r¿)Úvaluer¢r3cCs:zt|dd|dWStk
r4t|d|dYSXdS)Nrkrl)r™ršr¢Úlatin1)r™r¢)r€rM)rÀr¢rrrrYàsrYTrG)Úurlr#Úallow_fragmentsr3c s¾tjdtddt|ƒ‰t|tƒ}|dkr2ˆdƒ}ˆdƒ}}}| ˆdƒ¡}|dkr²t t    |d|…dd    ¡r²||d
d…}|rœt
‡fd d „|Dƒƒr²|d|…  ¡|}}|dd…ˆd ƒkrVt |ƒ}    ˆdƒD]"}
| |
d¡} | dkrØt |    | ƒ}    qØ|d|    …||    d…}}ˆdƒ|kr2ˆdƒ|ksNˆdƒ|krVˆdƒ|krVtdƒ‚|r~ˆdƒ|kr~| ˆdƒd
¡\}}ˆdƒ|kr | ˆdƒd
¡\}}|rªtnt} | |||||ƒS)aƒParses a URL from a string into a :class:`URL` tuple.  If the URL
    is lacking a scheme it can be provided as second argument. Otherwise,
    it is ignored.  Optionally fragments can be stripped from the URL
    by setting `allow_fragments` to `False`.
 
    The inverse of this function is :func:`url_unparse`.
 
    :param url: the URL to parse.
    :param scheme: the default schema to use if the URL is schemaless.
    :param allow_fragments: if set to `False` a fragment will be removed
                            from the URL.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlsplit`` instead.
    zq'werkzeug.urls.url_parse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlsplit' instead.r4r5NrgrhrrF)ršrc3s|]}|ˆdƒkVqdS)Ú
0123456789Nr©rÚc©ÚsrrÚ    <genexpr>
szurl_parse.<locals>.<genexpr>ú//ú/?#rirjzInvalid IPv6 URLú#ú?)r7r8r9r rKr"rÚ
_scheme_reÚmatchr ÚanyÚlowerrˆÚminrRr‡r–r—) rÂr#rÃZ is_text_basedr$r&r'Úir‘ÚdelimrÆÚwdelimZ result_typerrÇrrcçsDü
"   
ÿ
ÿrcrkrlú/:zt.Callable[[bytes], str])r™ršÚsafer¢r3csvtˆtƒrˆ ||¡‰t|tƒr,| ||¡}ttˆƒƒtBtt|ƒƒ‰‡fdd„tdƒDƒ‰dddœ‡fdd„ }|S)    a£Precompile the translation table for a URL encoding function.
 
    Unlike :func:`url_quote`, the generated function only takes the
    string to quote.
 
    :param charset: The charset to encode the result with.
    :param errors: How to handle encoding errors.
    :param safe: An optional sequence of safe characters to never encode.
    :param unsafe: An optional sequence of unsafe characters to always encode.
    cs(g|] }|ˆkrt|ƒn
d|d›‘qS)rr)ÚchrrÅ©r×rrr;sz(_make_fast_url_quote.<locals>.<listcomp>r rqr"©r¡r3csd ‡fdd„|Dƒ¡S)Nrgcsg|] }ˆ|‘qSrrrÅ©Útablerrr>sz7_make_fast_url_quote.<locals>.quote.<locals>.<listcomp>)re©r¡rÛrrr=sz#_make_fast_url_quote.<locals>.quote)rKr"rr¨r©Ú _always_safeÚrange)r™ršr×r¢rr)r×rÜrÚ_make_fast_url_quote$s
 
 ràú ú+)r×r¢rÚcCst|ƒ dd¡S)Nrárâ)Ú_fast_quote_plusrFrÝrrrr¼Gsr¼)r¡r™ršr×r¢r3cCsÊtjdtddt|tttfƒs(t|ƒ}t|tƒr>| ||¡}t|tƒrT| ||¡}t|tƒrj| ||¡}tt|ƒƒt    Btt|ƒƒ}tƒ}t|ƒD]&}||kr¬| 
|¡q”|  t |¡q”t|ƒ  |¡S)aªURL encode a single string with a given encoding.
 
    :param s: the string to quote.
    :param charset: the charset to be used.
    :param safe: an optional sequence of safe characters.
    :param unsafe: an optional sequence of unsafe characters.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote`` instead.
 
    .. versionadded:: 0.9.2
       The `unsafe` parameter was added.
    zn'werkzeug.urls.url_quote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.quote' instead.r4r5)r7r8r9rKr"rqr©rr¨rÞr¯r°Ú
_bytetohexrL)r¡r™ršr×r¢rOrrrrroKs(ü
 
 
   ro)r¡r™ršr×r3cCs,tjdtddt||||ddƒ dd¡S)aOURL encode a single string with the given encoding and convert
    whitespace to "+".
 
    :param s: The string to quote.
    :param charset: The charset to be used.
    :param safe: An optional sequence of safe characters.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.quote_plus`` instead.
    zx'werkzeug.urls.url_quote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.quote_plus' instead.r4r5rárâ)r7r8r9rorF)r¡r™ršr×rrrÚurl_quote_plusxs üråztuple[str, str, str, str, str])Ú
componentsr3cCsÖtjdtddt|ƒ|\}}}}}t|ƒ}|dƒ}|sL|rŠ| |dƒ¡rŠ|rp|dd…|dƒkrp|dƒ|}|dƒ|p€|dƒ|}n |r–||7}|rª||d    ƒ|}|r¾||d
ƒ|}|rÒ||d ƒ|}|S) aiThe reverse operation to :meth:`url_parse`.  This accepts arbitrary
    as well as :class:`URL` tuples and returns a URL as a string.
 
    :param components: the parsed URL as tuple which should be converted
                       into a URL string.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.urlunsplit`` instead.
    zu'werkzeug.urls.url_unparse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlunsplit' instead.r4r5rgr|NrrÊrhrÍrÌ)r7r8r9r    r rŽ)rær#r$r%r&r'rÈrÂrrrrfs,
ü rfrF)rÈr™ršr¢r3cCs2tjdtddt||ƒ}|dkr&|S| ||¡S)aÎURL decode a single string with a given encoding.  If the charset
    is set to `None` no decoding is performed and raw bytes are
    returned.
 
    :param s: the string to unquote.
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param errors: the error handling for the charset decoding.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote`` instead.
    zr'werkzeug.urls.url_unquote' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.unquote' instead.r4r5N)r7r8r9rµrL)rÈr™ršr¢rOrrrr€·sü
r€)rÈr™ršr3cCs@tjdtddt|tƒr(| dd¡}n | dd¡}t|||ƒS)a&URL decode a single string with the given `charset` and decode "+" to
    whitespace.
 
    Per default encoding errors are ignored.  If you want a different behavior
    you can set `errors` to ``'replace'`` or ``'strict'``.
 
    :param s: The string to unquote.
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param errors: The error handling for the `charset` decoding.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.unquote_plus`` instead.
    z|'werkzeug.urls.url_unquote_plus' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.unquote_plus' instead.r4r5râráó+ó )r7r8r9rKr"rFr€)rÈr™ršrrrÚurl_unquote_plusÕsü
 ré)rÈr™r3cCs°tjdtddt||dƒ dd¡}| d¡r`|dd    … ¡r`|d    d
…d kr`d |dd …›}t|ƒ}t|j    |dd}t
|j |dd}t
|j |dd}t |j| ¡|||fƒS)aFSometimes you get an URL by a user that just isn't a real URL because
    it contains unsafe characters like ' ' and so on. This function can fix
    some of the problems in a similar way browsers handle data entered by the
    user:
 
    >>> url_fix('http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)')
    'http://de.wikipedia.org/wiki/Elf%20(Begriffskl%C3%A4rung)'
 
    :param s: the string with the URL to fix.
    :param charset: The target charset for the URL if the url was given
        as a string.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0.
    zJ'werkzeug.urls.url_fix' is deprecated and will be removed in Werkzeug 3.0.r4r5rFr~r|zfile://ééé
)z:/z|/zfile:///Nz
/%+$!*'(),rÙz :&%=+$!*'(),)r7r8r9r rFrŽrƒrcror%rår&r'rfr#rp)rÈr™rÂr%ÚqsÚanchorrrrÚurl_fixõsý*rïrMztuple[str, int])Úer3cCs$t|j|j|j…dd}||jfS)zRUsed in :func:`uri_to_iri` after unquoting to re-quote any
    invalid bytes.
    rgrÙ)rÚobjectÚstartÚend)rðÚoutrrrÚ_codec_error_url_quotesrõúwerkzeug.url_quotez t.Callable[[str, str, str], str])r‚Úcharsr3csVd dd„t|ƒDƒ¡}t d|›dtj¡‰dddddœ‡fdd    „ }d
|›|_|S) zÑCreate a function that unquotes all percent encoded characters except those
    given. This allows working with unquoted characters if possible while not changing
    the meaning of a given part of a URL.
    ú|css|]}t|ƒd›VqdS)rN)ÚordrÅrrrrÉ-sz%_make_unquote_part.<locals>.<genexpr>z((?:%(?:z))+)r")rÀÚencodingršr3csHtˆ |¡ƒ}g}|D]&}| t|||ƒ¡| t|dƒ¡qd |¡S)Nrg)rªr‡r¯rr«re)rÀrúršrŠrôÚpart©ÚpatternrrÚ_unquote_partial0s z,_make_unquote_part.<locals>._unquote_partialZ    _unquote_)rer»ÚreÚcompileÚIr()r‚r÷ÚchoicesrþrrürÚ_make_unquote_part(s
 
ré!r§ér'r&z&=+#r%rËÚuserz:@/?#z$str | tuple[str, str, str, str, str])Úurir™ršr3c    CsJt|tƒr"tjdtddt|ƒ}t|tƒrDtjdtdd| ¡}|dk    r^tjdtddnd}|dk    r|tjdtddnd    }t|ƒ}t    |j
||ƒ}t |j ||ƒ}t |j||ƒ}|jrÄt|jƒ}nd
}d |krÜd |›d }|jrò|›d |j›}|jr6t|j||ƒ}|jr(|›d t|j||ƒ›}|›d|›}t|j||||fƒS)aConvert a URI to an IRI. All valid UTF-8 characters are unquoted,
    leaving all reserved and invalid characters quoted. If the URL has
    a domain, it is decoded from Punycode.
 
    >>> uri_to_iri("http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF")
    'http://\u2603.net/p\xe5th?q=\xe8ry%DF'
 
    :param uri: The URI to convert.
    :param charset: The encoding to encode unquoted bytes with.
    :param errors: Error handler to use during ``bytes.encode``. By
        default, invalid bytes are left quoted.
 
    .. versionchanged:: 2.3
        Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
        deprecated and will be removed in Werkzeug 3.0.
 
    .. versionchanged:: 2.3
        Which characters remain quoted is specific to each part of the URL.
 
    .. versionchanged:: 0.15
        All reserved and invalid characters remain quoted. Previously,
        only some reserved characters were preserved, and invalid bytes
        were replaced instead of left quoted.
 
    .. versionadded:: 0.6
    úHPassing a tuple is deprecated and will not be supported in Werkzeug 3.0.r4r5úFPassing bytes is deprecated and will not be supported in Werkzeug 3.0.NúJThe 'charset' parameter is deprecated and will be removed in Werkzeug 3.0.rkúIThe 'errors' parameter is deprecated and will be removed in Werkzeug 3.0.rörgrhrirjrm)rKÚtupler7r8r9rrqrLrÚ _unquote_pathr%Ú_unquote_queryr&Ú_unquote_fragmentr'Úhostnamer
rTrZÚ _unquote_userr]r#)    rr™ršrŠr%r&r'r$rVrrrruHsZ
ý
ýüý  ruz bool | None)Úirir™ršÚsafe_conversionr3c CsÀ|dk    rtjdtddnd}t|tƒr@tjdtddt|ƒ}t|tƒrdtjdtdd| |¡}|dk    r~tjdtddnd    }|dk    rštjd
tdd|rØz$| d ¡}t    | 
¡ƒd krÀ|WSWnt k
rÖYnXt |ƒ}t |jd ||d}t |jd||d}t |jd||d}|jr2|j d¡ d ¡}    nd}    d|    krLd|    ›d}    |jrd|    ›d|j›}    |jr¬t |jdd}
|jržt |jdd} |
›d| ›}
|
›d|    ›}    t|j|    |||fƒS)a Convert an IRI to a URI. All non-ASCII and unsafe characters are
    quoted. If the URL has a domain, it is encoded to Punycode.
 
    >>> iri_to_uri('http://\u2603.net/p\xe5th?q=\xe8ry%DF')
    'http://xn--n3h.net/p%C3%A5th?q=%C3%A8ry%DF'
 
    :param iri: The IRI to convert.
    :param charset: The encoding of the IRI.
    :param errors: Error handler to use during ``bytes.encode``.
 
    .. versionchanged:: 2.3
        Passing a tuple or bytes, and the ``charset`` and ``errors`` parameters, are
        deprecated and will be removed in Werkzeug 3.0.
 
    .. versionchanged:: 2.3
        Which characters remain unquoted is specific to each part of the URL.
 
    .. versionchanged:: 2.3
        The ``safe_conversion`` parameter is deprecated and will be removed in Werkzeug
        2.4.
 
    .. versionchanged:: 0.15
        All reserved characters remain unquoted. Previously, only some reserved
        characters were left unquoted.
 
    .. versionchanged:: 0.9.6
       The ``safe_conversion`` parameter was added.
 
    .. versionadded:: 0.6
    Nr
r4r5rkrr    r rlzRThe 'safe_conversion' parameter is deprecated and will be removed in Werkzeug 3.0.rrz%!$&'()*+,/:;=@)r×rúršz%!$&'()*+,/:;=?@z%!#$&'()*+,/:;=?@rJrgrhrirjz %!$&'()*+,;=rÙrm)r7r8r9rKr rrqrLrrˆr‡rMrrr%r&r'rrTrZr]r#) rr™ršrZ    ascii_irirŠr%r&r'r$rVZ pass_quotedrrrrs¥s€$ü
ý
ý
ýü
 
ÿ
 rs)rr3cCsDz| d¡Wntk
r"YnXt| dd¡ƒdkr<|St|ƒS)aØThe URL scheme ``itms-services://`` must contain the ``//`` even though it does
    not have a host component. There may be other invalid schemes as well. Currently,
    responses will always call ``iri_to_uri`` on the redirect ``Location`` header, which
    removes the ``//``. For now, if the IRI only contains ASCII and does not contain
    spaces, pass it on as-is. In Werkzeug 3.0, this should become a
    ``response.process_location`` flag.
 
    :meta private:
    rNr)rrMrˆr‡rs)rrrrÚ_invalid_iri_to_uri s
rú&zt.AnyStrztype[ds.MultiDict] | Noner_)rÈr™Ú include_emptyršÚ    separatorr<r3cCs†tjdtdd|dkr(ddlm}|}t|tƒrLt|tƒsL| |pFd¡}n"t|tƒrnt|tƒsn|     |pjd¡}|t
|  |¡|||ƒƒS)a²Parse a query string and return it as a :class:`MultiDict`.
 
    :param s: The query string to parse.
    :param charset: Decode bytes to string with this charset. If not
        given, bytes are returned as-is.
    :param include_empty: Include keys with empty values in the dict.
    :param errors: Error handling behavior when decoding bytes.
    :param separator: Separator character between pairs.
    :param cls: Container to hold result instead of :class:`MultiDict`.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0. Use ``urllib.parse.parse_qs`` instead.
 
    .. versionchanged:: 2.1
        The ``decode_keys`` parameter was removed.
 
    .. versionchanged:: 0.5
        In previous versions ";" and "&" could be used for url decoding.
        Now only "&" is supported. If you want to use ";", a different
        ``separator`` can be provided.
 
    .. versionchanged:: 0.5
        The ``cls`` parameter was added.
    zr'werkzeug.urls.url_decode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r4r5Nr©Ú    MultiDictr) r7r8r9rrrKr"rLrqrÚ_url_decode_implr‡)rÈr™rršrr<rrrrr`5s( ü ÿÿr`ó&z t.IO[bytes]rQ)Ústreamr™rršrr<Úlimitr3c CsVtjdtddddlm}||||ƒ}t||||ƒ}    |dkrNddlm}
|
}||    ƒS)ašWorks like :func:`url_decode` but decodes a stream.  The behavior
    of stream and limit follows functions like
    :func:`~werkzeug.wsgi.make_line_iter`.  The generator of pairs is
    directly fed to the `cls` so you can consume the data while it's
    parsed.
 
    :param stream: a stream with the encoded querystring
    :param charset: the charset of the query string.  If set to `None`
        no decoding will take place.
    :param include_empty: Set to `False` if you don't want empty values to
                          appear in the dict.
    :param errors: the decoding error behavior.
    :param separator: the pair separator to be used, defaults to ``&``
    :param cls: an optional dict class to use.  If this is not specified
                       or `None` the default :class:`MultiDict` is used.
    :param limit: the content length of the URL data.  Not necessary if
                  a limited stream is provided.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.parse_qs`` instead.
 
    .. versionchanged:: 2.1
        The ``decode_keys`` and ``return_iterator`` parameters were removed.
 
    .. versionadded:: 0.8
    zy'werkzeug.urls.url_decode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.r4r5r)Úmake_chunk_iterNr)r7r8r9Zwsgirrrr) rr™rršrr<rrÚ    pair_iterÚdecoderrrrrÚurl_decode_streamks#ü   r!zt.Iterable[t.AnyStr]zt.Iterator[tuple[str, str]])rr™rršr3c    csj|D]`}|sqt|ƒ}|dƒ}||kr8| |d¡\}}n|s>q|}|dƒ}t|||ƒt|||ƒfVqdS)Nrºrrg)r r‡ré)    rr™rršÚpairrÈÚequalr¹rÀrrrr¢s
 
þrF)r·r™r¸r¹rr3cCs.tjdtddt|dƒ}| t||||ƒ¡S)aPURL encode a dict/`MultiDict`.  If a value is `None` it will not appear
    in the result string.  Per default only values are encoded into the target
    charset strings.
 
    :param obj: the object to encode into a query string.
    :param charset: the charset of the query string.
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.
 
    .. versionchanged:: 2.1
        The ``encode_keys`` parameter was removed.
 
    .. versionchanged:: 0.5
        Added the ``sort``, ``key``, and ``separator`` parameters.
    zs'werkzeug.urls.url_encode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r4r5r)r7r8r9r rer¿)r·r™r¸r¹rrrrÚ
url_encode·sü
r$zt.IO[str] | NoneÚNone)r·rr™r¸r¹rr3c    Csbtjdtddt|dƒ}t||||ƒ}|dkr4|St|ƒD] \}}|rR| |¡| |¡q<dS)aËLike :meth:`url_encode` but writes the results to a stream
    object.  If the stream is `None` a generator over all encoded
    pairs is returned.
 
    :param obj: the object to encode into a query string.
    :param stream: a stream to write the encoded object into or `None` if
                   an iterator over the encoded pairs should be returned.  In
                   that case the separator argument is ignored.
    :param charset: the charset of the query string.
    :param sort: set to `True` if you want parameters to be sorted by `key`.
    :param separator: the separator to be used for the pairs.
    :param key: an optional function to be used for sorting.  For more details
                check out the :func:`sorted` documentation.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urlencode`` instead.
 
    .. versionchanged:: 2.1
        The ``encode_keys`` parameter was removed.
 
    .. versionadded:: 0.8
    zz'werkzeug.urls.url_encode_stream' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urlencode' instead.r4r5rN)r7r8r9r r¿Ú    enumerateÚwrite)    r·rr™r¸r¹rÚgenrÚchunkrrrÚurl_encode_streamÜsü
 
 r*)ÚbaserÂrÃr3csþtjdtddt|tƒr"t|ƒ}t|tƒr4t|ƒ}t||fƒt|ƒ‰|sP|S|sX|St||d\}}}}}t|||ƒ\}}    }
} } ||kr|S|    r¦t||    |
| | fƒS|}    |
dd…ˆdƒkrÎ|
     ˆdƒ¡} n@|
sê|     ˆdƒ¡} | sè|} n$|     ˆdƒ¡dd…|
     ˆdƒ¡} | dˆd    ƒkr,ˆd
ƒ| d<‡fd d „| Dƒ} d}t
| ƒd}||kr²| |ˆd ƒkrž| |dˆd
ƒˆd ƒfkrž| |d|d…=q>|d7}qNq²q>ˆd
ƒˆd ƒg}| dd…|krÞ| d=qˆdƒ  | ¡}
t||    |
| | fƒS)aqJoin a base URL and a possibly relative URL to form an absolute
    interpretation of the latter.
 
    :param base: the base URL for the join operation.
    :param url: the URL to join.
    :param allow_fragments: indicates whether fragments should be allowed.
 
    .. deprecated:: 2.3
        Will be removed in Werkzeug 2.4. Use ``urllib.parse.urljoin`` instead.
    zo'werkzeug.urls.url_join' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.urljoin' instead.r4r5)rÃNrr|éÿÿÿÿÚ.rgcsg|]}|ˆdƒkr|‘qS)r-r)rÚsegmentrÇrrrGs zurl_join.<locals>.<listcomp>z..) r7r8r9rKr rfr    r rcr‡rˆre)r+rÂrÃÚbschemeÚbnetlocÚbpathÚbqueryÚ    bfragmentr#r$r%r&r'ÚsegmentsrÓÚnZunwanted_markerrrÇrrd s`ü
 
 ÿ$  
0 
rd)r&rúr3cCs dd„t|ƒDƒ}t|d|dS)NcSsg|]}|ddk    r|‘qS)rNr)rÚxrrrr_s z_urlencode.<locals>.<listcomp>z !$'()*,/:;?@)r×rú)rr)r&rúr®rrrÚ
_urlencode\sr7)rg)rg)NT)rkrlrÖrg)rkrlrÖrg)rkrlrg)rkrFrg)rkrF)rk)r§r)NN)NNN)rkTrFrN)rkTrFrNN)rkFNr)NrkFNr)T)rk)Lr’Ú
__future__rÚcodecsrrÿÚtypingÚtr7Ú urllib.parserrrrrÚ    _internalr    r
r r rrÚ TYPE_CHECKINGrgZdsrrÎZ_always_safe_charsr¨rrÞrr­rßräÚ
NamedTupler!r,r–r—r r+rµr¿rYrcràZ_fast_url_quoterãr¼rorårfr€rérïrõÚregister_errorrrqrLZ_always_unsaferrr rrursrr`r!rr$r*rdr7rrrrÚ<module>sÞ            
ÿþ+!ÿ>ü û.ÿ*üÿ &
 
ý_ü{ú8ù7û'ú2ýRÿ