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
458e2fbf
Kaydet (Commit)
458e2fbf
authored
Eki 11, 2016
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27333 -- Prevented BASE64 encoding in message.as_string() on Python 3
Thanks Tim Graham for the review.
üst
bd7237d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
20 deletions
+13
-20
message.py
django/core/mail/message.py
+9
-20
tests.py
tests/mail/tests.py
+4
-0
No files found.
django/core/mail/message.py
Dosyayı görüntüle @
458e2fbf
...
...
@@ -211,31 +211,20 @@ class SafeMIMEText(MIMEMixin, MIMEText):
def
__init__
(
self
,
_text
,
_subtype
=
'plain'
,
_charset
=
None
):
self
.
encoding
=
_charset
if
_charset
==
'utf-8'
:
# 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
())
# Quoted-Printable encoding has the side effect of shortening long
# lines, if any (#22561).
self
.
set_payload
(
_text
,
utf8_charset_qp
if
has_long_lines
else
utf8_charset
)
self
.
replace_header
(
'Content-Type'
,
'text/
%
s; charset="
%
s"'
%
(
_subtype
,
_charset
))
elif
_charset
is
None
:
# the default value of '_charset' is 'us-ascii' on Python 2
MIMEText
.
__init__
(
self
,
_text
,
_subtype
)
else
:
MIMEText
.
__init__
(
self
,
_text
,
_subtype
,
_charset
)
MIMEText
.
__init__
(
self
,
_text
,
_subtype
=
_subtype
,
_charset
=
_charset
)
def
__setitem__
(
self
,
name
,
val
):
name
,
val
=
forbid_multi_line_headers
(
name
,
val
,
self
.
encoding
)
MIMEText
.
__setitem__
(
self
,
name
,
val
)
def
set_payload
(
self
,
payload
,
charset
=
None
):
if
charset
==
'utf-8'
:
has_long_lines
=
any
(
len
(
l
)
>
RFC5322_EMAIL_LINE_LENGTH_LIMIT
for
l
in
payload
.
splitlines
())
# Quoted-Printable encoding has the side effect of shortening long
# lines, if any (#22561).
charset
=
utf8_charset_qp
if
has_long_lines
else
utf8_charset
MIMEText
.
set_payload
(
self
,
payload
,
charset
=
charset
)
class
SafeMIMEMultipart
(
MIMEMixin
,
MIMEMultipart
):
...
...
tests/mail/tests.py
Dosyayı görüntüle @
458e2fbf
...
...
@@ -572,6 +572,8 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
)
s
=
msg
.
message
()
.
as_bytes
()
self
.
assertIn
(
b
'Content-Transfer-Encoding: 8bit'
,
s
)
s
=
msg
.
message
()
.
as_string
()
self
.
assertIn
(
str
(
'Content-Transfer-Encoding: 8bit'
),
s
)
msg
=
EmailMessage
(
'Subject'
,
'Body with non latin characters: А Б В Г Д Е Ж Ѕ З И І К Л М Н О П.'
,
'bounce@example.com'
,
...
...
@@ -579,6 +581,8 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
)
s
=
msg
.
message
()
.
as_bytes
()
self
.
assertIn
(
b
'Content-Transfer-Encoding: 8bit'
,
s
)
s
=
msg
.
message
()
.
as_string
()
self
.
assertIn
(
str
(
'Content-Transfer-Encoding: 8bit'
),
s
)
def
test_dont_base64_encode_message_rfc822
(
self
):
# Ticket #18967
...
...
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