<commit_before>import re
import itertools
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from django.conf import settings
from django.utils.encoding import force_unicode
from honeypot.decorators import verify_honeypot_value

# these were moved out of Django 1.2 -- we're going to still use them
_POST_FORM_RE = re.compile(r'(<form\W[^>]*\bmethod\s*=\s*(\'|"|)POST(\'|"|)\b[^>]*>)',
                           re.IGNORECASE)
_HTML_TYPES = ('text/html', 'application/xhtml+xml')

class HoneypotViewMiddleware(object):
    """
        Middleware that verifies a valid honeypot on all non-ajax POSTs.
    """
    def process_view(self, request, callback, callback_args, callback_kwargs):
        # TODO: this is temporary hardcode fix for forms that don't need honeypot
        if request.path_info == u'/intranet/tmp_upload/':
            return None
        if request.is_ajax():
            return None
        return verify_honeypot_value(request, None)<commit_msg>use settings to check for skipped urls<commit_after>import re
import itertools
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from django.conf import settings
from django.utils.encoding import force_unicode
from honeypot.decorators import verify_honeypot_value

# these were moved out of Django 1.2 -- we're going to still use them
_POST_FORM_RE = re.compile(r'(<form\W[^>]*\bmethod\s*=\s*(\'|"|)POST(\'|"|)\b[^>]*>)',
                           re.IGNORECASE)
_HTML_TYPES = ('text/html', 'application/xhtml+xml')

class HoneypotViewMiddleware(object):
    """
        Middleware that verifies a valid honeypot on all non-ajax POSTs.
    """
    def process_view(self, request, callback, callback_args, callback_kwargs):
        if request.is_ajax() or request.path_info in getattr(settings, 'HONEYPOT_SKIP_URLS', []):
            return None
        return verify_honeypot_value(request, None)
{'fraction_non_alphanumeric': 0.10861805201427843, 'fraction_numerical': 0.002039775624681285, 'mean_word_length': 3.727710843373494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6163366', 'n_tokens_mistral': 626, 'n_tokens_neox': 589, 'n_words': 163}