<commit_before>from flask import Request

from aleph.views.util import extract_next_url
from aleph.tests.util import TestCase


class ViewUtilTest(TestCase):

    def setUp(self):
        super(ViewUtilTest, self).setUp()

    def test_extract_next_url_blank(self):
        req = Request.from_values('')
        self.assertEqual('http://localhost:5000/', extract_next_url(req))

    def test_extract_next_url_unsafe(self):
        req = Request.from_values('/?next={}'.format(self.fake.url()))
        self.assertEqual('http://localhost:5000/', extract_next_url(req))

    def test_extract_next_url_safe(self):
        req = Request.from_values('/?next=/help')

        self.assertEqual('/help', extract_next_url(req))<commit_msg>Make extract_next_url fail<commit_after>from flask import Request

from aleph.views.util import extract_next_url
from aleph.tests.util import TestCase


class ViewUtilTest(TestCase):

    def setUp(self):
        super(ViewUtilTest, self).setUp()

    def test_extract_next_url_blank(self):
        req = Request.from_values('')
        self.assertEqual('http://localhost:5000/', extract_next_url(req))

    def test_extract_next_url_unsafe(self):
        req = Request.from_values('/?next={}'.format(self.fake.url()))
        self.assertEqual('http://localhost:5000/', extract_next_url(req))

    def test_extract_next_url_safe(self):
        headers = {'Referer': '/blah'}
        req = Request.from_values('/?next=/help', headers=headers)
        self.assertEqual('/help', extract_next_url(req))
{'fraction_non_alphanumeric': 0.13416230366492146, 'fraction_numerical': 0.010471204188481676, 'mean_word_length': 4.096666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6513036', 'n_tokens_mistral': 493, 'n_tokens_neox': 463, 'n_words': 77}