mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #28488 -- Reallowed error handlers to access CSRF tokens.
Regression in eef95ea96f.
This commit is contained in:
committed by
Tim Graham
parent
77f82c4bf1
commit
c4c128d67c
@@ -1,5 +1,6 @@
|
||||
from django.http import HttpResponse
|
||||
from django.template import RequestContext, Template
|
||||
from django.middleware.csrf import get_token
|
||||
from django.template import Context, RequestContext, Template
|
||||
from django.template.context_processors import csrf
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
|
||||
@@ -28,3 +29,9 @@ def non_token_view_using_request_processor(request):
|
||||
context = RequestContext(request, processors=[csrf])
|
||||
template = Template('')
|
||||
return HttpResponse(template.render(context))
|
||||
|
||||
|
||||
def csrf_token_error_handler(request, **kwargs):
|
||||
"""This error handler accesses the CSRF token."""
|
||||
template = Template(get_token(request))
|
||||
return HttpResponse(template.render(Context()), status=599)
|
||||
|
||||
Reference in New Issue
Block a user