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
844b0e69
Kaydet (Commit)
844b0e69
authored
Şub 04, 2013
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#16811: Fix folding of headers with no value in provisional policies.
üst
36b365cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
policy.py
Lib/email/policy.py
+1
-1
test_inversion.py
Lib/test/test_email/test_inversion.py
+45
-0
No files found.
Lib/email/policy.py
Dosyayı görüntüle @
844b0e69
...
...
@@ -173,7 +173,7 @@ class EmailPolicy(Policy):
lines
=
value
.
splitlines
()
refold
=
(
self
.
refold_source
==
'all'
or
self
.
refold_source
==
'long'
and
(
len
(
lines
[
0
])
+
len
(
name
)
+
2
>
maxlen
or
(
l
ines
and
l
en
(
lines
[
0
])
+
len
(
name
)
+
2
>
maxlen
or
any
(
len
(
x
)
>
maxlen
for
x
in
lines
[
1
:])))
if
refold
or
refold_binary
and
_has_surrogates
(
value
):
return
self
.
header_factory
(
name
,
''
.
join
(
lines
))
.
fold
(
policy
=
self
)
...
...
Lib/test/test_email/test_inversion.py
0 → 100644
Dosyayı görüntüle @
844b0e69
"""Test the parser and generator are inverses.
Note that this is only strictly true if we are parsing RFC valid messages and
producing RFC valid messages.
"""
import
io
import
unittest
from
email
import
policy
,
message_from_bytes
from
email.generator
import
BytesGenerator
from
test.test_email
import
TestEmailBase
,
parameterize
# This is like textwrap.dedent for bytes, except that it uses \r\n for the line
# separators on the rebuilt string.
def
dedent
(
bstr
):
lines
=
bstr
.
splitlines
()
if
not
lines
[
0
]
.
strip
():
raise
ValueError
(
"First line must contain text"
)
stripamt
=
len
(
lines
[
0
])
-
len
(
lines
[
0
]
.
lstrip
())
return
b
'
\r\n
'
.
join
(
[
x
[
stripamt
:]
if
len
(
x
)
>=
stripamt
else
b
''
for
x
in
lines
])
@parameterize
class
TestInversion
(
TestEmailBase
,
unittest
.
TestCase
):
def
msg_as_input
(
self
,
msg
):
m
=
message_from_bytes
(
msg
,
policy
=
policy
.
SMTP
)
b
=
io
.
BytesIO
()
g
=
BytesGenerator
(
b
)
g
.
flatten
(
m
)
self
.
assertEqual
(
b
.
getvalue
(),
msg
)
# XXX: spaces are not preserved correctly here yet in the general case.
msg_params
=
{
'header_with_one_space_body'
:
(
dedent
(
b
"""
\
From: abc@xyz.com
X-Status:
\x20
Subject: test
foo
"""
),),
}
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