mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[1.11.x] Fixed #28488 -- Reallowed error handlers to access CSRF tokens.
Regression ineef95ea96f. Backport ofc4c128d67cfrom master
This commit is contained in:
committed by
Tim Graham
parent
19ea298aaf
commit
42847327d1
@@ -1,7 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
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
|
||||
|
||||
@@ -30,3 +31,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