Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
7fd55c34
Kaydet (Commit)
7fd55c34
authored
Haz 30, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20631 -- Increased the default EmailField max_length to 254.
Thanks pmartin for the report.
üst
1966054f
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
46 additions
and
17 deletions
+46
-17
0003_alter_user_email_max_length.py
...ntrib/auth/migrations/0003_alter_user_email_max_length.py
+19
-0
validators.py
django/core/validators.py
+3
-1
__init__.py
django/db/models/fields/__init__.py
+2
-4
fields.txt
docs/ref/models/fields.txt
+4
-8
1.8.txt
docs/releases/1.8.txt
+11
-0
tests.py
tests/field_deconstruction/tests.py
+1
-1
tests.py
tests/inspectdb/tests.py
+1
-1
tests.py
tests/introspection/tests.py
+1
-1
tests.py
tests/max_lengths/tests.py
+1
-1
tests.py
tests/validators/tests.py
+3
-0
No files found.
django/contrib/auth/migrations/0003_alter_user_email_max_length.py
0 → 100644
Dosyayı görüntüle @
7fd55c34
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'auth'
,
'0002_alter_permission_name_max_length'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'email'
,
field
=
models
.
EmailField
(
max_length
=
254
,
verbose_name
=
'email address'
,
blank
=
True
),
),
]
django/core/validators.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -124,7 +124,9 @@ class EmailValidator(object):
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)'
,
# quoted-string
re
.
IGNORECASE
)
domain_regex
=
re
.
compile
(
r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,}(?<!-))$'
,
# max length of the domain is 251: 254 (max email length) minus one
# period and two characters for the TLD.
r'(?:[A-Z0-9](?:[A-Z0-9-]{0,249}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,}(?<!-))$'
,
re
.
IGNORECASE
)
literal_regex
=
re
.
compile
(
# literal form, ipv4 or ipv6 address (SMTP 4.1.3)
...
...
django/db/models/fields/__init__.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -1567,10 +1567,8 @@ class EmailField(CharField):
description
=
_
(
"Email address"
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
# max_length should be overridden to 254 characters to be fully
# compliant with RFCs 3696 and 5321
kwargs
[
'max_length'
]
=
kwargs
.
get
(
'max_length'
,
75
)
# max_length=254 to be compliant with RFCs 3696 and 5321
kwargs
[
'max_length'
]
=
kwargs
.
get
(
'max_length'
,
254
)
super
(
EmailField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
deconstruct
(
self
):
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
7fd55c34
...
...
@@ -535,18 +535,14 @@ The default form widget for this field is a :class:`~django.forms.TextInput`.
``EmailField``
--------------
.. class:: EmailField([max_length=
75
, **options])
.. class:: EmailField([max_length=
254
, **options])
A :class:`CharField` that checks that the value is a valid email address.
..
admonition:: Incompliance to RFCs
..
versionchanged:: 1.8
The default 75 character ``max_length`` is not capable of storing all
possible RFC3696/5321-compliant email addresses. In order to store all
possible valid email addresses, a ``max_length`` of 254 is required.
The default ``max_length`` of 75 exists for historical reasons. The
default has not been changed in order to maintain backwards
compatibility with existing uses of :class:`EmailField`.
The default ``max_length`` was increased from 75 to 254 in order to be
compliant with RFC3696/5321.
``FileField``
-------------
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
7fd55c34
...
...
@@ -373,6 +373,17 @@ lookups::
...
ValueError: Cannot query "<Book: Django>": Must be "Author" instance.
Default ``EmailField.max_length`` increased to 254
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The old default 75 character ``max_length`` was not capable of storing all
possible RFC3696/5321-compliant email addresses. In order to store all
possible valid email addresses, the ``max_length`` has been increased to 254
characters. You will need to generate and apply database migrations for your
affected models (or add ``max_length=75`` if you wish to keep the length on
your current fields). A migration for
:attr:`django.contrib.auth.models.User.email` is included.
Miscellaneous
~~~~~~~~~~~~~
...
...
tests/field_deconstruction/tests.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -128,7 +128,7 @@ class FieldDeconstructionTests(TestCase):
name
,
path
,
args
,
kwargs
=
field
.
deconstruct
()
self
.
assertEqual
(
path
,
"django.db.models.EmailField"
)
self
.
assertEqual
(
args
,
[])
self
.
assertEqual
(
kwargs
,
{
"max_length"
:
75
})
self
.
assertEqual
(
kwargs
,
{
"max_length"
:
254
})
field
=
models
.
EmailField
(
max_length
=
255
)
name
,
path
,
args
,
kwargs
=
field
.
deconstruct
()
self
.
assertEqual
(
path
,
"django.db.models.EmailField"
)
...
...
tests/inspectdb/tests.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -54,7 +54,7 @@ class InspectDBTestCase(TestCase):
assertFieldType
(
'date_time_field'
,
"models.DateTimeField()"
)
if
(
connection
.
features
.
can_introspect_max_length
and
not
connection
.
features
.
interprets_empty_strings_as_nulls
):
assertFieldType
(
'email_field'
,
"models.CharField(max_length=
75
)"
)
assertFieldType
(
'email_field'
,
"models.CharField(max_length=
254
)"
)
assertFieldType
(
'file_field'
,
"models.CharField(max_length=100)"
)
assertFieldType
(
'file_path_field'
,
"models.CharField(max_length=100)"
)
if
connection
.
features
.
can_introspect_ip_address_field
:
...
...
tests/introspection/tests.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -70,7 +70,7 @@ class IntrospectionTests(TestCase):
desc
=
connection
.
introspection
.
get_table_description
(
cursor
,
Reporter
.
_meta
.
db_table
)
self
.
assertEqual
(
[
r
[
3
]
for
r
in
desc
if
datatype
(
r
[
1
],
r
)
==
'CharField'
],
[
30
,
30
,
75
]
[
30
,
30
,
254
]
)
@skipUnlessDBFeature
(
'can_introspect_null'
)
...
...
tests/max_lengths/tests.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -11,7 +11,7 @@ class MaxLengthArgumentsTests(unittest.TestCase):
self
.
assertEqual
(
model
.
_meta
.
get_field
(
field
)
.
max_length
,
length
)
def
test_default_max_lengths
(
self
):
self
.
verify_max_length
(
PersonWithDefaultMaxLengths
,
'email'
,
75
)
self
.
verify_max_length
(
PersonWithDefaultMaxLengths
,
'email'
,
254
)
self
.
verify_max_length
(
PersonWithDefaultMaxLengths
,
'vcard'
,
100
)
self
.
verify_max_length
(
PersonWithDefaultMaxLengths
,
'homepage'
,
200
)
self
.
verify_max_length
(
PersonWithDefaultMaxLengths
,
'avatar'
,
100
)
...
...
tests/validators/tests.py
Dosyayı görüntüle @
7fd55c34
...
...
@@ -66,6 +66,9 @@ TEST_DATA = (
(
validate_email
,
'"
\\\011
"@here.com'
,
None
),
(
validate_email
,
'"
\\\012
"@here.com'
,
ValidationError
),
(
validate_email
,
'trailingdot@shouldfail.com.'
,
ValidationError
),
# Max length of domain name in email is 251 (see validator for calculation)
(
validate_email
,
'a@
%
s.com'
%
(
'a'
*
251
),
None
),
(
validate_email
,
'a@
%
s.com'
%
(
'a'
*
252
),
ValidationError
),
(
validate_slug
,
'slug-ok'
,
None
),
(
validate_slug
,
'longer-slug-still-ok'
,
None
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment