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
6ac3a6fa
Commit
6ac3a6fa
authored
Nov 29, 2004
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RFC 2822 describes the characters allowed in a header field name. Conform to
this, and add test cases.
parent
6712446c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
Lib/email/FeedParser.py
Lib/email/FeedParser.py
+3
-1
Lib/email/test/test_email.py
Lib/email/test/test_email.py
+16
-0
No files found.
Lib/email/FeedParser.py
View file @
6ac3a6fa
...
...
@@ -27,7 +27,9 @@ NLCRE = re.compile('\r\n|\r|\n')
NLCRE_bol
=
re
.
compile
(
'(
\
r
\
n
|
\
r
|
\
n
)'
)
NLCRE_eol
=
re
.
compile
(
'(
\
r
\
n
|
\
r
|
\
n
)$'
)
NLCRE_crack
=
re
.
compile
(
'(
\
r
\
n
|
\
r
|
\
n
)'
)
headerRE
=
re
.
compile
(
r'^(From |[-\
w]{
2,}:|[\t ])'
)
# RFC 2822 $3.6.8 Optional fields. ftext is %d33-57 / %d59-126, Any character
# except controls, SP, and ":".
headerRE
=
re
.
compile
(
r'^(From |[\041-\071\073-\176]{2,}:|[\t ])'
)
EMPTYSTRING
=
''
NL
=
'
\
n
'
...
...
Lib/email/test/test_email.py
View file @
6ac3a6fa
...
...
@@ -2402,6 +2402,22 @@ Here's the message body
eq
(
msg
.
get
(
'Header'
),
value1
)
eq
(
msg
.
get
(
'Next-Header'
),
value2
)
def
test_rfc2822_header_syntax
(
self
):
eq
=
self
.
assertEqual
m
=
'>From: foo
\
n
From: bar
\
n
!"#QUX;~: zoo
\
n
\
n
body'
msg
=
email
.
message_from_string
(
m
)
eq
(
len
(
msg
.
keys
()),
3
)
keys
=
msg
.
keys
()
keys
.
sort
()
eq
(
keys
,
[
'!"#QUX;~'
,
'>From'
,
'From'
])
eq
(
msg
.
get_payload
(),
'body'
)
def
test_rfc2822_space_not_allowed_in_header
(
self
):
eq
=
self
.
assertEqual
m
=
'>From foo@example.com 11:25:53
\
n
From: bar
\
n
!"#QUX;~: zoo
\
n
\
n
body'
msg
=
email
.
message_from_string
(
m
)
eq
(
len
(
msg
.
keys
()),
0
)
class
TestBase64
(
unittest
.
TestCase
):
...
...
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