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
b90a8be9
Kaydet (Commit)
b90a8be9
authored
Agu 15, 2008
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#2676: email/message.py [Message.get_content_type]: Trivial regex hangs on pathological input
üst
a174a373
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
message.py
Lib/email/message.py
+11
-7
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/email/message.py
Dosyayı görüntüle @
b90a8be9
...
...
@@ -19,18 +19,22 @@ from email import errors
SEMISPACE
=
'; '
# Regular expression used to split header parameters. BAW: this may be too
# simple. It isn't strictly RFC 2045 (section 5.1) compliant, but it catches
# most headers found in the wild. We may eventually need a full fledged
# parser eventually.
paramre
=
re
.
compile
(
r'\s*;\s*'
)
# Regular expression that matches `special' characters in parameters, the
# existance of which force quoting of the parameter value.
tspecials
=
re
.
compile
(
r'[ \(\)<>@,;:\\"/\[\]\?=]'
)
# Helper functions
def
_splitparam
(
param
):
# Split header parameters. BAW: this may be too simple. It isn't
# strictly RFC 2045 (section 5.1) compliant, but it catches most headers
# found in the wild. We may eventually need a full fledged parser
# eventually.
a
,
sep
,
b
=
param
.
partition
(
';'
)
if
not
sep
:
return
a
.
strip
(),
None
return
a
.
strip
(),
b
.
strip
()
def
_formatparam
(
param
,
value
=
None
,
quote
=
True
):
"""Convenience function to format and return a key=value pair.
...
...
@@ -436,7 +440,7 @@ class Message:
if
value
is
missing
:
# This should have no parameters
return
self
.
get_default_type
()
ctype
=
paramre
.
split
(
value
)[
0
]
.
lower
()
.
strip
()
ctype
=
_splitparam
(
value
)[
0
]
.
lower
()
# RFC 2045, section 5.2 says if its invalid, use text/plain
if
ctype
.
count
(
'/'
)
!=
1
:
return
'text/plain'
...
...
Misc/NEWS
Dosyayı görüntüle @
b90a8be9
...
...
@@ -48,6 +48,10 @@ Core and Builtins
Library
-------
- Issue #2676: in the email package, content-type parsing was hanging on
pathological input because of quadratic or exponential behaviour of a
regular expression.
- Issue #3476: binary buffered reading through the new "io" library is now
thread-safe.
...
...
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