[Zope-Checkins] CVS: Zope/lib/python/Products/MIMETools -
MIMETag.py:1.12
Kiran Jonnalagadda
jace at pobox.com
Tue Dec 30 01:23:54 EST 2003
Update of /cvs-repository/Zope/lib/python/Products/MIMETools
In directory cvs.zope.org:/tmp/cvs-serv14156
Modified Files:
MIMETag.py
Log Message:
Added charset and charset_expr attributes. The charset header is inserted only for text/* content types and defaults to "us-ascii". The MIME spec says this header is optional, but Spam Assassin considers its absence a likely indicator of spam.
=== Zope/lib/python/Products/MIMETools/MIMETag.py 1.11 => 1.12 ===
--- Zope/lib/python/Products/MIMETools/MIMETag.py:1.11 Thu Dec 25 02:24:47 2003
+++ Zope/lib/python/Products/MIMETools/MIMETag.py Tue Dec 30 01:23:52 2003
@@ -41,6 +41,7 @@
, name=None, name_expr=None
, filename=None, filename_expr=None
, cid=None, cid_expr=None
+ , charset=None, charset_expr=None
, skip_expr=None
, multipart=None
)
@@ -53,6 +54,7 @@
, name=None, name_expr=None
, filename=None, filename_expr=None
, cid=None, cid_expr=None
+ , charset=None, charset_expr=None
, skip_expr=None
)
@@ -105,6 +107,13 @@
elif not has_key('cid'):
args['cid']=''
+ if has_key('charset_expr'):
+ if has_key('charset'):
+ raise ParseError, _tm('charset and charset_expr given', 'mime')
+ args['charset_expr']=Eval(args['charset_expr'])
+ elif not has_key('charset'):
+ args['charset']=''
+
if has_key('skip_expr'):
args['skip_expr']=Eval(args['skip_expr'])
@@ -150,6 +159,9 @@
if has_key('cid_expr'): cid=a['cid_expr'].eval(md)
else: cid=a['cid']
+ if has_key('charset_expr'): charset=a['charset_expr'].eval(md)
+ else: charset=a['charset']
+
if d:
if f:
inner.addheader('Content-Disposition', '%s;\n filename="%s"' % (d, f))
@@ -165,6 +177,9 @@
plist = [('name', n)]
else:
plist = []
+
+ if t.startswith('text/'):
+ plist.append(('charset', charset or 'us-ascii'))
innerfile = inner.startbody(t, plist, 1)
More information about the Zope-Checkins
mailing list