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
b7e3b547
Commit
b7e3b547
authored
Jun 10, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fix by Sjoerd
parent
7ab9e99b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
Lib/mimify.py
Lib/mimify.py
+12
-3
No files found.
Lib/mimify.py
View file @
b7e3b547
...
...
@@ -29,8 +29,10 @@ QUOTE = '> ' # string replies are quoted with
import
regex
,
regsub
,
string
qp
=
regex
.
compile
(
'^content-transfer-encoding:[
\
000
-
\
377
]*quoted-printable'
,
qp
=
regex
.
compile
(
'^content-transfer-encoding:[
\
t
]*quoted-printable'
,
regex
.
casefold
)
base64
=
regex
.
compile
(
'^content-transfer-encoding:[
\
t
]*base64'
,
regex
.
casefold
)
mp
=
regex
.
compile
(
'^content-type:[
\
000
-
\
377
]*multipart/[
\
000
-
\
377
]*boundary="?
\
\
([^;"
\
n
]*
\
\
)'
,
regex
.
casefold
)
chrset
=
regex
.
compile
(
'^
\
\
(content-type:.*charset="
\
\
)
\
\
(us-ascii
\
\
|iso-8859-[0-9]+
\
\
)
\
\
("[
\
000
-
\
377
]*
\
\
)'
,
...
...
@@ -261,7 +263,7 @@ iso_char = regex.compile('[\240-\377]')
def
mimify_part
(
ifile
,
ofile
,
is_mime
):
'''Convert an 8bit part of a MIME mail message to quoted-printable.'''
has_cte
=
is_qp
=
0
has_cte
=
is_qp
=
is_base64
=
0
multipart
=
None
must_quote_body
=
must_quote_header
=
has_iso_chars
=
0
...
...
@@ -283,6 +285,8 @@ def mimify_part(ifile, ofile, is_mime):
has_cte
=
1
if
qp
.
match
(
line
)
>=
0
:
is_qp
=
1
elif
base64
.
match
(
line
)
>=
0
:
is_base64
=
1
if
mp
.
match
(
line
)
>=
0
:
multipart
=
'--'
+
mp
.
group
(
1
)
if
he
.
match
(
line
)
>=
0
:
...
...
@@ -302,6 +306,9 @@ def mimify_part(ifile, ofile, is_mime):
if
line
==
multipart
+
'
\
n
'
:
message_end
=
line
break
if
is_base64
:
message
.
append
(
line
)
continue
if
is_qp
:
while
line
[
-
2
:]
==
'=
\
n
'
:
line
=
line
[:
-
2
]
...
...
@@ -333,7 +340,9 @@ def mimify_part(ifile, ofile, is_mime):
line
=
chrset
.
group
(
1
)
+
'us-ascii'
+
chrset
.
group
(
3
)
if
has_cte
and
cte
.
match
(
line
)
>=
0
:
line
=
'Content-Transfer-Encoding: '
if
must_quote_body
:
if
is_base64
:
line
=
line
+
'base64
\
n
'
elif
must_quote_body
:
line
=
line
+
'quoted-printable
\
n
'
else
:
line
=
line
+
'7bit
\
n
'
...
...
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