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
e76ff408
Kaydet (Commit)
e76ff408
authored
Haz 18, 2011
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge #11584: make Header and make_header handle binary unknown-8bit input
üst
7df08379
e5e366c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
header.py
Lib/email/header.py
+4
-1
test_email.py
Lib/test/test_email/test_email.py
+15
-0
NEWS
Misc/NEWS
+2
-1
No files found.
Lib/email/header.py
Dosyayı görüntüle @
e76ff408
...
...
@@ -275,7 +275,10 @@ class Header:
charset
=
Charset
(
charset
)
if
not
isinstance
(
s
,
str
):
input_charset
=
charset
.
input_codec
or
'us-ascii'
s
=
s
.
decode
(
input_charset
,
errors
)
if
input_charset
==
_charset
.
UNKNOWN8BIT
:
s
=
s
.
decode
(
'us-ascii'
,
'surrogateescape'
)
else
:
s
=
s
.
decode
(
input_charset
,
errors
)
# Ensure that the bytes we're storing can be decoded to the output
# character set, otherwise an early error is thrown.
output_charset
=
charset
.
output_codec
or
'us-ascii'
...
...
Lib/test/test_email/test_email.py
Dosyayı görüntüle @
e76ff408
...
...
@@ -4330,6 +4330,21 @@ A very long line that must get split to something other than at the
'Ynwp4dUEbay Auction Semiar- No Charge
\uFFFD
Earn Big'
)
self
.
assertEqual
(
email
.
header
.
decode_header
(
h
),
[(
x
,
'unknown-8bit'
)])
def
test_header_handles_binary_unknown8bit
(
self
):
x
=
b
'Ynwp4dUEbay Auction Semiar- No Charge
\x96
Earn Big'
h
=
Header
(
x
,
charset
=
email
.
charset
.
UNKNOWN8BIT
)
self
.
assertEqual
(
str
(
h
),
'Ynwp4dUEbay Auction Semiar- No Charge
\uFFFD
Earn Big'
)
self
.
assertEqual
(
email
.
header
.
decode_header
(
h
),
[(
x
,
'unknown-8bit'
)])
def
test_make_header_handles_binary_unknown8bit
(
self
):
x
=
b
'Ynwp4dUEbay Auction Semiar- No Charge
\x96
Earn Big'
h
=
Header
(
x
,
charset
=
email
.
charset
.
UNKNOWN8BIT
)
h2
=
email
.
header
.
make_header
(
email
.
header
.
decode_header
(
h
))
self
.
assertEqual
(
str
(
h2
),
'Ynwp4dUEbay Auction Semiar- No Charge
\uFFFD
Earn Big'
)
self
.
assertEqual
(
email
.
header
.
decode_header
(
h2
),
[(
x
,
'unknown-8bit'
)])
def
test_modify_returned_list_does_not_change_header
(
self
):
h
=
Header
(
'test'
)
chunks
=
email
.
header
.
decode_header
(
h
)
...
...
Misc/NEWS
Dosyayı görüntüle @
e76ff408
...
...
@@ -194,7 +194,8 @@ Library
-------
- Issue #11584: email.header.decode_header no longer fails if the header
passed to it is a Header object.
passed to it is a Header object, and Header/make_header no longer fail
if given binary unknown-8bit input.
- Issue #11700: mailbox proxy object close methods can now be called multiple
times without error.
...
...
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