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
04b7b288
Kaydet (Commit)
04b7b288
authored
Tem 01, 2016
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26802 -- Prevented crash when attaching bytes as text message
Thanks Tim Graham for the review.
üst
9356f63a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
message.py
django/core/mail/message.py
+6
-2
tests.py
tests/mail/tests.py
+8
-0
No files found.
django/core/mail/message.py
Dosyayı görüntüle @
04b7b288
...
...
@@ -212,9 +212,13 @@ class SafeMIMEText(MIMEMixin, MIMEText):
def
__init__
(
self
,
_text
,
_subtype
=
'plain'
,
_charset
=
None
):
self
.
encoding
=
_charset
if
_charset
==
'utf-8'
:
# Unfortunately, Python < 3.5 doesn't support setting a Charset instance
# as MIMEText init parameter (http://bugs.python.org/issue16324).
# Unfortunately, Python doesn't yet pass a Charset instance as
# MIMEText init parameter to set_payload().
# http://bugs.python.org/issue27445
# We do it manually and trigger re-encoding of the payload.
if
six
.
PY3
and
isinstance
(
_text
,
bytes
):
# Sniffing encoding would fail with bytes content in MIMEText.__init__.
_text
=
_text
.
decode
(
'utf-8'
)
MIMEText
.
__init__
(
self
,
_text
,
_subtype
,
None
)
del
self
[
'Content-Transfer-Encoding'
]
has_long_lines
=
any
(
len
(
l
)
>
RFC5322_EMAIL_LINE_LENGTH_LIMIT
for
l
in
_text
.
splitlines
())
...
...
tests/mail/tests.py
Dosyayı görüntüle @
04b7b288
...
...
@@ -390,6 +390,14 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
msgs_sent_num
=
email
.
send
()
self
.
assertEqual
(
msgs_sent_num
,
1
)
def
test_attach_text_as_bytes
(
self
):
msg
=
EmailMessage
(
'subject'
,
'body'
,
'from@example.com'
,
[
'to@example.com'
])
file_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
upath
(
__file__
)),
'attachments'
,
'file.txt'
)
with
open
(
file_path
,
mode
=
'rb'
)
as
fh
:
msg
.
attach
(
'file.txt'
,
fh
.
read
())
sent_num
=
msg
.
send
()
self
.
assertEqual
(
sent_num
,
1
)
def
test_dummy_backend
(
self
):
"""
Make sure that dummy backends returns correct number of sent messages
...
...
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