Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
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
cpython
Commits
c723da36
Kaydet (Commit)
c723da36
authored
Haz 27, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge #14360: make encoders.encode_quopri work.
üst
cd83fa8c
f6069f9f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
encoders.py
Lib/email/encoders.py
+6
-2
test_email.py
Lib/test/test_email/test_email.py
+29
-0
No files found.
Lib/email/encoders.py
Dosyayı görüntüle @
c723da36
...
...
@@ -20,7 +20,7 @@ from quopri import encodestring as _encodestring
def
_qencode
(
s
):
enc
=
_encodestring
(
s
,
quotetabs
=
True
)
# Must encode spaces, which quopri.encodestring() doesn't do
return
enc
.
replace
(
' '
,
'=20'
)
return
enc
.
replace
(
b
' '
,
b
'=20'
)
def
encode_base64
(
msg
):
...
...
@@ -41,8 +41,12 @@ def encode_quopri(msg):
Also, add an appropriate Content-Transfer-Encoding header.
"""
orig
=
msg
.
get_payload
()
if
isinstance
(
orig
,
str
):
# If it is a string, the model data may have binary data encoded in via
# surrogateescape. Convert back to bytes so we can CTE encode it.
orig
=
orig
.
encode
(
'ascii'
,
'surrogateescape'
)
encdata
=
_qencode
(
orig
)
msg
.
set_payload
(
encdata
)
msg
.
set_payload
(
encdata
.
decode
(
'ascii'
,
'surrogateescape'
)
)
msg
[
'Content-Transfer-Encoding'
]
=
'quoted-printable'
...
...
Lib/test/test_email/test_email.py
Dosyayı görüntüle @
c723da36
...
...
@@ -1474,6 +1474,35 @@ class TestMIMEApplication(unittest.TestCase):
self
.
assertEqual
(
msg
.
get_payload
(),
'
\uFFFD
'
*
len
(
bytesdata
))
self
.
assertEqual
(
msg2
.
get_payload
(
decode
=
True
),
bytesdata
)
def
test_binary_body_with_encode_quopri
(
self
):
# Issue 14360.
bytesdata
=
b
'
\xfa\xfb\xfc\xfd\xfe\xff
'
msg
=
MIMEApplication
(
bytesdata
,
_encoder
=
encoders
.
encode_quopri
)
self
.
assertEqual
(
msg
.
get_payload
(),
'=FA=FB=FC=FD=FE=FF=20'
)
self
.
assertEqual
(
msg
.
get_payload
(
decode
=
True
),
bytesdata
)
self
.
assertEqual
(
msg
[
'Content-Transfer-Encoding'
],
'quoted-printable'
)
s
=
BytesIO
()
g
=
BytesGenerator
(
s
)
g
.
flatten
(
msg
)
wireform
=
s
.
getvalue
()
msg2
=
email
.
message_from_bytes
(
wireform
)
self
.
assertEqual
(
msg
.
get_payload
(),
'=FA=FB=FC=FD=FE=FF=20'
)
self
.
assertEqual
(
msg2
.
get_payload
(
decode
=
True
),
bytesdata
)
self
.
assertEqual
(
msg2
[
'Content-Transfer-Encoding'
],
'quoted-printable'
)
def
test_binary_body_with_encode_base64
(
self
):
bytesdata
=
b
'
\xfa\xfb\xfc\xfd\xfe\xff
'
msg
=
MIMEApplication
(
bytesdata
,
_encoder
=
encoders
.
encode_base64
)
self
.
assertEqual
(
msg
.
get_payload
(),
'+vv8/f7/
\n
'
)
self
.
assertEqual
(
msg
.
get_payload
(
decode
=
True
),
bytesdata
)
s
=
BytesIO
()
g
=
BytesGenerator
(
s
)
g
.
flatten
(
msg
)
wireform
=
s
.
getvalue
()
msg2
=
email
.
message_from_bytes
(
wireform
)
self
.
assertEqual
(
msg
.
get_payload
(),
'+vv8/f7/
\n
'
)
self
.
assertEqual
(
msg2
.
get_payload
(
decode
=
True
),
bytesdata
)
# Test the basic MIMEText class
class
TestMIMEText
(
unittest
.
TestCase
):
...
...
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