diff --git a/django/core/validators.py b/django/core/validators.py index 94ec34ea03..852ff49358 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -104,8 +104,6 @@ class URLValidator(RegexValidator): r'\Z', re.IGNORECASE) message = _('Enter a valid URL.') schemes = ['http', 'https', 'ftp', 'ftps'] - unsafe_chars = frozenset('\t\r\n') - max_length = 2048 def __init__(self, schemes=None, **kwargs): super(URLValidator, self).__init__(**kwargs) @@ -114,10 +112,6 @@ class URLValidator(RegexValidator): def __call__(self, value): value = force_text(value) - if not isinstance(value, str) or len(value) > self.max_length: - raise ValidationError(self.message, code=self.code, params={'value': value}) - if self.unsafe_chars.intersection(value): - raise ValidationError(self.message, code=self.code) # Check first if the scheme is valid scheme = value.split('://')[0].lower() if scheme not in self.schemes: @@ -189,9 +183,7 @@ class EmailValidator(object): def __call__(self, value): value = force_text(value) - # The maximum length of an email is 320 characters per RFC 3696 - # section 3. - if not value or '@' not in value or len(value) > 320: + if not value or '@' not in value: raise ValidationError(self.message, code=self.code) user_part, domain_part = value.rsplit('@', 1) diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index d7e10d817e..9d9eb3c3ba 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -24,12 +24,10 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): c.execute('PRAGMA foreign_keys') self._initial_pragma_fk = c.fetchone()[0] c.execute('PRAGMA foreign_keys = 0') - self.connection.cursor().execute('PRAGMA legacy_alter_table = ON') return super(DatabaseSchemaEditor, self).__enter__() def __exit__(self, exc_type, exc_value, traceback): super(DatabaseSchemaEditor, self).__exit__(exc_type, exc_value, traceback) - self.connection.cursor().execute('PRAGMA legacy_alter_table = OFF') with self.connection.cursor() as c: # Restore initial FK setting - PRAGMA values can't be parametrized c.execute('PRAGMA foreign_keys = %s' % int(self._initial_pragma_fk)) diff --git a/django/forms/fields.py b/django/forms/fields.py index d5040bc376..e59cf81890 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -546,12 +546,6 @@ class EmailField(CharField): widget = EmailInput default_validators = [validators.validate_email] - def __init__(self, *args, **kwargs): - # The default maximum length of an email is 320 characters per RFC 3696 - # section 3. - kwargs.setdefault("max_length", 320) - super(EmailField, self).__init__(*args, strip=True, **kwargs) - def clean(self, value): value = self.to_python(value).strip() return super(EmailField, self).clean(value) diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py index 93b078bb6e..17b8756ddb 100644 --- a/tests/forms_tests/tests/test_fields.py +++ b/tests/forms_tests/tests/test_fields.py @@ -805,10 +805,7 @@ class FieldsTests(SimpleTestCase): def test_emailfield_1(self): f = EmailField() - self.assertEqual(f.max_length, 320) - self.assertWidgetRendersTo( - f, '' - ) + self.assertWidgetRendersTo(f, '') self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, '') self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None) self.assertEqual('person@example.com', f.clean('person@example.com')) diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index dd3c6b7682..6492b1eda0 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -416,17 +416,11 @@ class FormsTestCase(SimpleTestCase): get_spam = BooleanField() f = SignupForm(auto_id=False) - self.assertHTMLEqual( - str(f["email"]), - '', - ) + self.assertHTMLEqual(str(f['email']), '') self.assertHTMLEqual(str(f['get_spam']), '') f = SignupForm({'email': 'test@example.com', 'get_spam': True}, auto_id=False) - self.assertHTMLEqual( - str(f["email"]), - '', - ) + self.assertHTMLEqual(str(f['email']), '') self.assertHTMLEqual(str(f['get_spam']), '') # 'True' or 'true' should be rendered without a value attribute @@ -2601,7 +2595,7 @@ Good luck picking a username that doesn't already exist.

-
  • +
  • """ ) @@ -2617,7 +2611,7 @@ Good luck picking a username that doesn't already exist.

    -

    +

    """ @@ -2636,7 +2630,7 @@ Good luck picking a username that doesn't already exist.

    - + """ @@ -3222,7 +3216,7 @@ Good luck picking a username that doesn't already exist.

    f = CommentForm(data, auto_id=False, error_class=DivErrorList) self.assertHTMLEqual(f.as_p(), """

    Name:

    Enter a valid email address.
    -

    Email:

    +

    Email:

    This field is required.

    Comment:

    """) diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 8deecd5c7c..772ddc51f7 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -192,13 +192,11 @@ class RequestsTests(SimpleTestCase): "Cookie will expire when an distant expiration time is provided" response = HttpResponse() response.set_cookie('datetime', expires=datetime(2028, 1, 1, 4, 5, 6)) - response.set_cookie('datetime', expires=datetime(2038, 1, 1, 4, 5, 6)) datetime_cookie = response.cookies['datetime'] self.assertIn( datetime_cookie['expires'], # Slight time dependency; refs #23450 ('Sat, 01-Jan-2028 04:05:06 GMT', 'Sat, 01-Jan-2028 04:05:07 GMT') - ('Fri, 01-Jan-2038 04:05:06 GMT', 'Fri, 01-Jan-2038 04:05:07 GMT') ) def test_max_age_expiration(self): diff --git a/tests/validators/tests.py b/tests/validators/tests.py index 6e774cedd7..f696f8e573 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -54,7 +54,6 @@ TEST_DATA = [ (validate_email, 'example@atm.%s' % ('a' * 64), ValidationError), (validate_email, 'example@%s.atm.%s' % ('b' * 64, 'a' * 63), ValidationError), - (validate_email, "example@%scom" % (("a" * 63 + ".") * 100), ValidationError), (validate_email, None, ValidationError), (validate_email, '', ValidationError), (validate_email, 'abc', ValidationError), @@ -208,11 +207,6 @@ TEST_DATA = [ (URLValidator(EXTENDED_SCHEMES), 'git://example.com/', None), (URLValidator(EXTENDED_SCHEMES), 'git://-invalid.com', ValidationError), - ( - URLValidator(), - "http://example." + ("a" * 63 + ".") * 1000 + "com", - ValidationError, - ), # Trailing newlines not accepted (URLValidator(), 'http://www.djangoproject.com/\n', ValidationError), (URLValidator(), 'http://[::ffff:192.9.5.5]\n', ValidationError),