lol
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
import re
|
||||
import typing as t
|
||||
import uuid
|
||||
import warnings
|
||||
from urllib.parse import quote
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
@@ -42,17 +41,8 @@ class BaseConverter:
|
||||
return value
|
||||
|
||||
def to_url(self, value: t.Any) -> str:
|
||||
if isinstance(value, (bytes, bytearray)):
|
||||
warnings.warn(
|
||||
"Passing bytes as a URL value is deprecated and will not be supported"
|
||||
" in Werkzeug 3.0.",
|
||||
DeprecationWarning,
|
||||
stacklevel=7,
|
||||
)
|
||||
return quote(value, safe="!$&'()*+,/:;=@")
|
||||
|
||||
# safe = https://url.spec.whatwg.org/#url-path-segment-string
|
||||
return quote(str(value), encoding=self.map.charset, safe="!$&'()*+,/:;=@")
|
||||
return quote(str(value), safe="!$&'()*+,/:;=@")
|
||||
|
||||
|
||||
class UnicodeConverter(BaseConverter):
|
||||
@@ -129,6 +119,7 @@ class PathConverter(BaseConverter):
|
||||
:param map: the :class:`Map`.
|
||||
"""
|
||||
|
||||
part_isolating = False
|
||||
regex = "[^/].*?"
|
||||
weight = 200
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ class Map:
|
||||
:param rules: sequence of url rules for this map.
|
||||
:param default_subdomain: The default subdomain for rules without a
|
||||
subdomain defined.
|
||||
:param charset: charset of the url. defaults to ``"utf-8"``
|
||||
:param strict_slashes: If a rule ends with a slash but the matched
|
||||
URL does not, redirect to the URL with a trailing slash.
|
||||
:param merge_slashes: Merge consecutive slashes when matching or
|
||||
@@ -62,15 +61,13 @@ class Map:
|
||||
:param sort_parameters: If set to `True` the url parameters are sorted.
|
||||
See `url_encode` for more details.
|
||||
:param sort_key: The sort key function for `url_encode`.
|
||||
:param encoding_errors: the error method to use for decoding
|
||||
:param host_matching: if set to `True` it enables the host matching
|
||||
feature and disables the subdomain one. If
|
||||
enabled the `host` parameter to rules is used
|
||||
instead of the `subdomain` one.
|
||||
|
||||
.. versionchanged:: 2.3
|
||||
The ``charset`` and ``encoding_errors`` parameters are deprecated and will be
|
||||
removed in Werkzeug 3.0.
|
||||
.. versionchanged:: 3.0
|
||||
The ``charset`` and ``encoding_errors`` parameters were removed.
|
||||
|
||||
.. versionchanged:: 1.0
|
||||
If ``url_scheme`` is ``ws`` or ``wss``, only WebSocket rules will match.
|
||||
@@ -97,14 +94,12 @@ class Map:
|
||||
self,
|
||||
rules: t.Iterable[RuleFactory] | None = None,
|
||||
default_subdomain: str = "",
|
||||
charset: str | None = None,
|
||||
strict_slashes: bool = True,
|
||||
merge_slashes: bool = True,
|
||||
redirect_defaults: bool = True,
|
||||
converters: t.Mapping[str, type[BaseConverter]] | None = None,
|
||||
sort_parameters: bool = False,
|
||||
sort_key: t.Callable[[t.Any], t.Any] | None = None,
|
||||
encoding_errors: str | None = None,
|
||||
host_matching: bool = False,
|
||||
) -> None:
|
||||
self._matcher = StateMachineMatcher(merge_slashes)
|
||||
@@ -113,30 +108,6 @@ class Map:
|
||||
self._remap_lock = self.lock_class()
|
||||
|
||||
self.default_subdomain = default_subdomain
|
||||
|
||||
if charset is not None:
|
||||
warnings.warn(
|
||||
"The 'charset' parameter is deprecated and will be"
|
||||
" removed in Werkzeug 3.0.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
else:
|
||||
charset = "utf-8"
|
||||
|
||||
self.charset = charset
|
||||
|
||||
if encoding_errors is not None:
|
||||
warnings.warn(
|
||||
"The 'encoding_errors' parameter is deprecated and will be"
|
||||
" removed in Werkzeug 3.0.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
else:
|
||||
encoding_errors = "replace"
|
||||
|
||||
self.encoding_errors = encoding_errors
|
||||
self.strict_slashes = strict_slashes
|
||||
self.merge_slashes = merge_slashes
|
||||
self.redirect_defaults = redirect_defaults
|
||||
@@ -362,7 +333,7 @@ class Map:
|
||||
def _get_wsgi_string(name: str) -> str | None:
|
||||
val = env.get(name)
|
||||
if val is not None:
|
||||
return _wsgi_decoding_dance(val, self.charset)
|
||||
return _wsgi_decoding_dance(val)
|
||||
return None
|
||||
|
||||
script_name = _get_wsgi_string("SCRIPT_NAME")
|
||||
@@ -629,9 +600,7 @@ class MapAdapter:
|
||||
result = self.map._matcher.match(domain_part, path_part, method, websocket)
|
||||
except RequestPath as e:
|
||||
# safe = https://url.spec.whatwg.org/#url-path-segment-string
|
||||
new_path = quote(
|
||||
e.path_info, safe="!$&'()*+,/:;=@", encoding=self.map.charset
|
||||
)
|
||||
new_path = quote(e.path_info, safe="!$&'()*+,/:;=@")
|
||||
raise RequestRedirect(
|
||||
self.make_redirect_url(new_path, query_args)
|
||||
) from None
|
||||
@@ -767,7 +736,7 @@ class MapAdapter:
|
||||
|
||||
def encode_query_args(self, query_args: t.Mapping[str, t.Any] | str) -> str:
|
||||
if not isinstance(query_args, str):
|
||||
return _urlencode(query_args, encoding=self.map.charset)
|
||||
return _urlencode(query_args)
|
||||
return query_args
|
||||
|
||||
def make_redirect_url(
|
||||
|
||||
@@ -583,7 +583,7 @@ class Rule(RuleFactory):
|
||||
if self.map.sort_parameters:
|
||||
items = sorted(items, key=self.map.sort_key)
|
||||
|
||||
return _urlencode(items, encoding=self.map.charset)
|
||||
return _urlencode(items)
|
||||
|
||||
def _parse_rule(self, rule: str) -> t.Iterable[RulePart]:
|
||||
content = ""
|
||||
@@ -739,12 +739,7 @@ class Rule(RuleFactory):
|
||||
opl.append((False, data))
|
||||
elif not is_dynamic:
|
||||
# safe = https://url.spec.whatwg.org/#url-path-segment-string
|
||||
opl.append(
|
||||
(
|
||||
False,
|
||||
quote(data, safe="!$&'()*+,/:;=@", encoding=self.map.charset),
|
||||
)
|
||||
)
|
||||
opl.append((False, quote(data, safe="!$&'()*+,/:;=@")))
|
||||
else:
|
||||
opl.append((True, data))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user