Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c968b443
Commit
c968b443
authored
Aug 20, 2002
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for SF patch #597593, syntactically invalid Content-Type: headers.
parent
6c97897d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
Lib/email/test/test_email.py
Lib/email/test/test_email.py
+23
-2
No files found.
Lib/email/test/test_email.py
View file @
c968b443
...
@@ -428,12 +428,12 @@ class TestMessageAPI(TestEmailBase):
...
@@ -428,12 +428,12 @@ class TestMessageAPI(TestEmailBase):
def
test_get_content_maintype_error
(
self
):
def
test_get_content_maintype_error
(
self
):
msg
=
Message
()
msg
=
Message
()
msg
[
'Content-Type'
]
=
'no-slash-in-this-string'
msg
[
'Content-Type'
]
=
'no-slash-in-this-string'
self
.
assert
Raises
(
ValueError
,
msg
.
get_content_maintype
)
self
.
assert
Equal
(
msg
.
get_content_maintype
(),
'text'
)
def
test_get_content_subtype_error
(
self
):
def
test_get_content_subtype_error
(
self
):
msg
=
Message
()
msg
=
Message
()
msg
[
'Content-Type'
]
=
'no-slash-in-this-string'
msg
[
'Content-Type'
]
=
'no-slash-in-this-string'
self
.
assert
Raises
(
ValueError
,
msg
.
get_content_subtype
)
self
.
assert
Equal
(
msg
.
get_content_subtype
(),
'plain'
)
...
@@ -1007,6 +1007,27 @@ class TestNonConformant(TestEmailBase):
...
@@ -1007,6 +1007,27 @@ class TestNonConformant(TestEmailBase):
finally
:
finally
:
fp
.
close
()
fp
.
close
()
def
test_invalid_content_type
(
self
):
eq
=
self
.
assertEqual
neq
=
self
.
ndiffAssertEqual
msg
=
Message
()
# RFC 2045, $5.2 says invalid yields text/plain
msg
[
'Content-Type'
]
=
'text'
eq
(
msg
.
get_content_maintype
(),
'text'
)
eq
(
msg
.
get_content_subtype
(),
'plain'
)
eq
(
msg
.
get_content_type
(),
'text/plain'
)
# Clear the old value and try something /really/ invalid
del
msg
[
'content-type'
]
msg
[
'Content-Type'
]
=
'foo'
eq
(
msg
.
get_content_maintype
(),
'text'
)
eq
(
msg
.
get_content_subtype
(),
'plain'
)
eq
(
msg
.
get_content_type
(),
'text/plain'
)
# Still, make sure that the message is idempotently generated
s
=
StringIO
()
g
=
Generator
(
s
)
g
.
flatten
(
msg
)
neq
(
s
.
getvalue
(),
'Content-Type: foo
\
n
\
n
'
)
# Test RFC 2047 header encoding and decoding
# Test RFC 2047 header encoding and decoding
...
...
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