lol
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import typing as t
|
||||
import warnings
|
||||
from datetime import datetime
|
||||
from urllib.parse import parse_qsl
|
||||
|
||||
@@ -59,95 +58,13 @@ class Request:
|
||||
:param headers: The headers received with the request.
|
||||
:param remote_addr: The address of the client sending the request.
|
||||
|
||||
.. versionchanged:: 3.0
|
||||
The ``charset``, ``url_charset``, and ``encoding_errors`` attributes
|
||||
were removed.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
"""
|
||||
|
||||
_charset: str
|
||||
|
||||
@property
|
||||
def charset(self) -> str:
|
||||
"""The charset used to decode body, form, and cookie data. Defaults to UTF-8.
|
||||
|
||||
.. deprecated:: 2.3
|
||||
Will be removed in Werkzeug 3.0. Request data must always be UTF-8.
|
||||
"""
|
||||
warnings.warn(
|
||||
"The 'charset' attribute is deprecated and will not be used in Werkzeug"
|
||||
" 2.4. Interpreting bytes as text in body, form, and cookie data will"
|
||||
" always use UTF-8.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._charset
|
||||
|
||||
@charset.setter
|
||||
def charset(self, value: str) -> None:
|
||||
warnings.warn(
|
||||
"The 'charset' attribute is deprecated and will not be used in Werkzeug"
|
||||
" 2.4. Interpreting bytes as text in body, form, and cookie data will"
|
||||
" always use UTF-8.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._charset = value
|
||||
|
||||
_encoding_errors: str
|
||||
|
||||
@property
|
||||
def encoding_errors(self) -> str:
|
||||
"""How errors when decoding bytes are handled. Defaults to "replace".
|
||||
|
||||
.. deprecated:: 2.3
|
||||
Will be removed in Werkzeug 3.0.
|
||||
"""
|
||||
warnings.warn(
|
||||
"The 'encoding_errors' attribute is deprecated and will not be used in"
|
||||
" Werkzeug 3.0.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._encoding_errors
|
||||
|
||||
@encoding_errors.setter
|
||||
def encoding_errors(self, value: str) -> None:
|
||||
warnings.warn(
|
||||
"The 'encoding_errors' attribute is deprecated and will not be used in"
|
||||
" Werkzeug 3.0.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._encoding_errors = value
|
||||
|
||||
_url_charset: str
|
||||
|
||||
@property
|
||||
def url_charset(self) -> str:
|
||||
"""The charset to use when decoding percent-encoded bytes in :attr:`args`.
|
||||
Defaults to the value of :attr:`charset`, which defaults to UTF-8.
|
||||
|
||||
.. deprecated:: 2.3
|
||||
Will be removed in Werkzeug 3.0. Percent-encoded bytes must always be UTF-8.
|
||||
|
||||
.. versionadded:: 0.6
|
||||
"""
|
||||
warnings.warn(
|
||||
"The 'url_charset' attribute is deprecated and will not be used in"
|
||||
" Werkzeug 3.0. Percent-encoded bytes must always be UTF-8.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self._url_charset
|
||||
|
||||
@url_charset.setter
|
||||
def url_charset(self, value: str) -> None:
|
||||
warnings.warn(
|
||||
"The 'url_charset' attribute is deprecated and will not be used in"
|
||||
" Werkzeug 3.0. Percent-encoded bytes must always be UTF-8.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._url_charset = value
|
||||
|
||||
#: the class to use for `args` and `form`. The default is an
|
||||
#: :class:`~werkzeug.datastructures.ImmutableMultiDict` which supports
|
||||
#: multiple values per key. alternatively it makes sense to use an
|
||||
@@ -209,40 +126,6 @@ class Request:
|
||||
headers: Headers,
|
||||
remote_addr: str | None,
|
||||
) -> None:
|
||||
if not isinstance(type(self).charset, property):
|
||||
warnings.warn(
|
||||
"The 'charset' attribute is deprecated and will not be used in Werkzeug"
|
||||
" 2.4. Interpreting bytes as text in body, form, and cookie data will"
|
||||
" always use UTF-8.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._charset = self.charset
|
||||
else:
|
||||
self._charset = "utf-8"
|
||||
|
||||
if not isinstance(type(self).encoding_errors, property):
|
||||
warnings.warn(
|
||||
"The 'encoding_errors' attribute is deprecated and will not be used in"
|
||||
" Werkzeug 3.0.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._encoding_errors = self.encoding_errors
|
||||
else:
|
||||
self._encoding_errors = "replace"
|
||||
|
||||
if not isinstance(type(self).url_charset, property):
|
||||
warnings.warn(
|
||||
"The 'url_charset' attribute is deprecated and will not be used in"
|
||||
" Werkzeug 3.0. Percent-encoded bytes must always be UTF-8.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self._url_charset = self.url_charset
|
||||
else:
|
||||
self._url_charset = self._charset
|
||||
|
||||
#: The method the request was made with, such as ``GET``.
|
||||
self.method = method.upper()
|
||||
#: The URL scheme of the protocol the request used, such as
|
||||
@@ -291,7 +174,6 @@ class Request:
|
||||
parse_qsl(
|
||||
self.query_string.decode(),
|
||||
keep_blank_values=True,
|
||||
encoding=self._url_charset,
|
||||
errors="werkzeug.url_quote",
|
||||
)
|
||||
)
|
||||
@@ -360,13 +242,8 @@ class Request:
|
||||
"""A :class:`dict` with the contents of all cookies transmitted with
|
||||
the request."""
|
||||
wsgi_combined_cookie = ";".join(self.headers.getlist("Cookie"))
|
||||
charset = self._charset if self._charset != "utf-8" else None
|
||||
errors = self._encoding_errors if self._encoding_errors != "replace" else None
|
||||
return parse_cookie( # type: ignore
|
||||
wsgi_combined_cookie,
|
||||
charset=charset,
|
||||
errors=errors,
|
||||
cls=self.dict_storage_class,
|
||||
wsgi_combined_cookie, cls=self.dict_storage_class
|
||||
)
|
||||
|
||||
# Common Descriptors
|
||||
|
||||
Reference in New Issue
Block a user