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
f581b372
Kaydet (Commit)
f581b372
authored
Şub 05, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#16948: Fix quopri encoding of non-latin1 character sets.
üst
43536e9e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
charset.py
Lib/email/charset.py
+13
-0
test_email.py
Lib/email/test/test_email.py
+21
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/email/charset.py
Dosyayı görüntüle @
f581b372
...
...
@@ -392,6 +392,19 @@ class Charset:
string
=
string
.
encode
(
self
.
output_charset
)
return
email
.
base64mime
.
body_encode
(
string
)
elif
self
.
body_encoding
is
QP
:
# quopromime.body_encode takes a string, but operates on it as if
# it were a list of byte codes. For a (minimal) history on why
# this is so, see changeset 0cf700464177. To correctly encode a
# character set, then, we must turn it into pseudo bytes via the
# latin1 charset, which will encode any byte as a single code point
# between 0 and 255, which is what body_encode is expecting.
#
# Note that this clause doesn't handle the case of a _payload that
# is already bytes. It never did, and the semantics of _payload
# being bytes has never been nailed down, so fixing that is a
# longer term TODO.
if
isinstance
(
string
,
str
):
string
=
string
.
encode
(
self
.
output_charset
)
.
decode
(
'latin1'
)
return
email
.
quoprimime
.
body_encode
(
string
)
else
:
if
isinstance
(
string
,
str
):
...
...
Lib/email/test/test_email.py
Dosyayı görüntüle @
f581b372
...
...
@@ -670,6 +670,27 @@ class TestEncoders(unittest.TestCase):
msg
=
MIMEText
(
'文'
,
_charset
=
'euc-jp'
)
eq
(
msg
[
'content-transfer-encoding'
],
'7bit'
)
def
test_qp_encode_latin1
(
self
):
msg
=
MIMEText
(
'
\xe1\xf6\n
'
,
'text'
,
'ISO-8859-1'
)
self
.
assertEqual
(
str
(
msg
),
textwrap
.
dedent
(
"""
\
MIME-Version: 1.0
Content-Type: text/text; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
=E1=F6
"""
))
def
test_qp_encode_non_latin1
(
self
):
# Issue 16948
msg
=
MIMEText
(
'
\u017c\n
'
,
'text'
,
'ISO-8859-2'
)
self
.
assertEqual
(
str
(
msg
),
textwrap
.
dedent
(
"""
\
MIME-Version: 1.0
Content-Type: text/text; charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
=BF
"""
))
# Test long header wrapping
class
TestLongHeaders
(
TestEmailBase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
f581b372
...
...
@@ -212,6 +212,10 @@ Core and Builtins
Library
-------
- Issue #16948: Fix quoted printable body encoding for non-latin1 character
sets in the email package.
- Issue #17089: Expat parser now correctly works with string input not only when
an internal XML encoding is UTF-8 or US-ASCII. It now accepts bytes and
strings larger than 2 GiB.
...
...
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