diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-08-25 12:54:32 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-08-25 13:03:33 +0300 |
commit | 4a64a813e1d34e732f35d8a65147974f76395a6f (patch) | |
tree | a8da0dede5213f85e45b95047cfbdcf5427cf0b7 /contrib/python/Twisted/py3/twisted/web/resource.py | |
parent | e9bbee265681b79a9ef9795bdc84cf6996f9cfec (diff) | |
download | ydb-4a64a813e1d34e732f35d8a65147974f76395a6f.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/Twisted/py3/twisted/web/resource.py')
-rw-r--r-- | contrib/python/Twisted/py3/twisted/web/resource.py | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/contrib/python/Twisted/py3/twisted/web/resource.py b/contrib/python/Twisted/py3/twisted/web/resource.py index 456db72d12..56595d2995 100644 --- a/contrib/python/Twisted/py3/twisted/web/resource.py +++ b/contrib/python/Twisted/py3/twisted/web/resource.py @@ -28,7 +28,7 @@ from incremental import Version from twisted.python.compat import nativeString from twisted.python.components import proxyForInterface -from twisted.python.deprecate import deprecatedModuleAttribute +from twisted.python.deprecate import deprecated from twisted.python.reflect import prefixedMethodNames from twisted.web._responses import FORBIDDEN, NOT_FOUND from twisted.web.error import UnsupportedMethod @@ -294,15 +294,9 @@ def _computeAllowedMethods(resource): return allowedMethods -class _UnsafeErrorPage(Resource): +class _UnsafeErrorPageBase(Resource): """ - L{_UnsafeErrorPage}, publicly available via the deprecated alias - C{ErrorPage}, is a resource which responds with a particular - (parameterized) status and a body consisting of HTML containing some - descriptive text. This is useful for rendering simple error pages. - - Deprecated in Twisted 22.10.0 because it permits HTML injection; use - L{twisted.web.pages.errorPage} instead. + Base class for deprecated error page resources. @ivar template: A native string which will have a dictionary interpolated into it to generate the response body. The dictionary has the following @@ -355,7 +349,26 @@ class _UnsafeErrorPage(Resource): return self -class _UnsafeNoResource(_UnsafeErrorPage): +class _UnsafeErrorPage(_UnsafeErrorPageBase): + """ + L{_UnsafeErrorPage}, publicly available via the deprecated alias + C{ErrorPage}, is a resource which responds with a particular + (parameterized) status and a body consisting of HTML containing some + descriptive text. This is useful for rendering simple error pages. + + Deprecated in Twisted 22.10.0 because it permits HTML injection; use + L{twisted.web.pages.errorPage} instead. + """ + + @deprecated( + Version("Twisted", 22, 10, 0), + "Use twisted.web.pages.errorPage instead, which properly escapes HTML.", + ) + def __init__(self, status, brief, detail): + _UnsafeErrorPageBase.__init__(self, status, brief, detail) + + +class _UnsafeNoResource(_UnsafeErrorPageBase): """ L{_UnsafeNoResource}, publicly available via the deprecated alias C{NoResource}, is a specialization of L{_UnsafeErrorPage} which @@ -365,11 +378,15 @@ class _UnsafeNoResource(_UnsafeErrorPage): L{twisted.web.pages.notFound} instead. """ + @deprecated( + Version("Twisted", 22, 10, 0), + "Use twisted.web.pages.notFound instead, which properly escapes HTML.", + ) def __init__(self, message="Sorry. No luck finding that resource."): - _UnsafeErrorPage.__init__(self, NOT_FOUND, "No Such Resource", message) + _UnsafeErrorPageBase.__init__(self, NOT_FOUND, "No Such Resource", message) -class _UnsafeForbiddenResource(_UnsafeErrorPage): +class _UnsafeForbiddenResource(_UnsafeErrorPageBase): """ L{_UnsafeForbiddenResource}, publicly available via the deprecated alias C{ForbiddenResource} is a specialization of L{_UnsafeErrorPage} which @@ -379,8 +396,12 @@ class _UnsafeForbiddenResource(_UnsafeErrorPage): L{twisted.web.pages.forbidden} instead. """ + @deprecated( + Version("Twisted", 22, 10, 0), + "Use twisted.web.pages.forbidden instead, which properly escapes HTML.", + ) def __init__(self, message="Sorry, resource is forbidden."): - _UnsafeErrorPage.__init__(self, FORBIDDEN, "Forbidden Resource", message) + _UnsafeErrorPageBase.__init__(self, FORBIDDEN, "Forbidden Resource", message) # Deliberately undocumented public aliases. See GHSA-vg46-2rrj-3647. @@ -388,27 +409,6 @@ ErrorPage = _UnsafeErrorPage NoResource = _UnsafeNoResource ForbiddenResource = _UnsafeForbiddenResource -deprecatedModuleAttribute( - Version("Twisted", 22, 10, 0), - "Use twisted.web.pages.errorPage instead, which properly escapes HTML.", - __name__, - "ErrorPage", -) - -deprecatedModuleAttribute( - Version("Twisted", 22, 10, 0), - "Use twisted.web.pages.notFound instead, which properly escapes HTML.", - __name__, - "NoResource", -) - -deprecatedModuleAttribute( - Version("Twisted", 22, 10, 0), - "Use twisted.web.pages.forbidden instead, which properly escapes HTML.", - __name__, - "ForbiddenResource", -) - class _IEncodingResource(Interface): """ |