""" Cross Site Request Forgery Middleware. This module provides a middleware that implements protection against request forgeries from other sites. """ import re import itertools try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.3, 2.4 fallback. from django.conf import settings from django.http import HttpResponseForbidden from django.utils.hashcompat import md5_constructor from django.utils.safestring import mark_safe _ERROR_MSG = mark_safe('
Cross Site Request Forgery detected. Request aborted.
') _POST_FORM_RE = \ re.compile(r'(