Fix doco nit from qzrrbz@github
This commit is contained in:
+9
-3
@@ -327,7 +327,9 @@ class Base(object):
|
|||||||
# to pass bytes to @link #header the header callback @endlink instead,
|
# to pass bytes to @link #header the header callback @endlink instead,
|
||||||
# or trap utf-8 conversion exception, etc.
|
# or trap utf-8 conversion exception, etc.
|
||||||
def envfrom_bytes(self,*b):
|
def envfrom_bytes(self,*b):
|
||||||
s = (v.decode(encoding='utf-8',errors='surrogateescape') for v in b)
|
try:
|
||||||
|
s = (v.decode(encoding='utf-8') for v in b)
|
||||||
|
except UnicodeDecodeError: s = b
|
||||||
return self.envfrom(fld,*s)
|
return self.envfrom(fld,*s)
|
||||||
## Called when the SMTP client says MAIL FROM. Called by the
|
## Called when the SMTP client says MAIL FROM. Called by the
|
||||||
# <a href="milter_api/xxfi_envfrom.html">
|
# <a href="milter_api/xxfi_envfrom.html">
|
||||||
@@ -346,7 +348,9 @@ class Base(object):
|
|||||||
# to pass bytes to @link #header the header callback @endlink instead,
|
# to pass bytes to @link #header the header callback @endlink instead,
|
||||||
# or trap utf-8 conversion exception, etc.
|
# or trap utf-8 conversion exception, etc.
|
||||||
def envrcpt_bytes(self,*b):
|
def envrcpt_bytes(self,*b):
|
||||||
s = (v.decode(encoding='utf-8',errors='surrogateescape') for v in b)
|
try:
|
||||||
|
s = (v.decode(encoding='utf-8') for v in b)
|
||||||
|
except UnicodeDecodeError: s = b
|
||||||
return self.envrcpt(fld,*s)
|
return self.envrcpt(fld,*s)
|
||||||
## Called when the SMTP client says RCPT TO. Called by the
|
## Called when the SMTP client says RCPT TO. Called by the
|
||||||
# <a href="milter_api/xxfi_envrcpt.html">
|
# <a href="milter_api/xxfi_envrcpt.html">
|
||||||
@@ -372,7 +376,9 @@ class Base(object):
|
|||||||
# Converts from utf-8 to unicode with surrogate escape. Can be overriden
|
# Converts from utf-8 to unicode with surrogate escape. Can be overriden
|
||||||
# to pass bytes to @link #header the header callback @endlink instead.
|
# to pass bytes to @link #header the header callback @endlink instead.
|
||||||
def header_bytes(self,fld,val):
|
def header_bytes(self,fld,val):
|
||||||
s = val.decode(encoding='utf-8',errors='surrogateescape')
|
try:
|
||||||
|
s = val.decode(encoding='utf-8')
|
||||||
|
except UnicodeDecodeError: s = val
|
||||||
return self.header(fld,s)
|
return self.header(fld,s)
|
||||||
## Called for each header field in the message body.
|
## Called for each header field in the message body.
|
||||||
# @param field name decoded as ascii
|
# @param field name decoded as ascii
|
||||||
|
|||||||
+1
-1
@@ -234,7 +234,7 @@ class TestCtx(object):
|
|||||||
else:
|
else:
|
||||||
v = val.encode(encoding='ascii',errors='surrogateescape')
|
v = val.encode(encoding='ascii',errors='surrogateescape')
|
||||||
# invoke the Milter header_callback
|
# invoke the Milter header_callback
|
||||||
return Milter.header_callback(self,fld,v)
|
return self._priv.header_bytes(fld,v)
|
||||||
|
|
||||||
def _eoh(self):
|
def _eoh(self):
|
||||||
if self._protocol & Milter.P_NOEOH:
|
if self._protocol & Milter.P_NOEOH:
|
||||||
|
|||||||
+1
-1
@@ -250,7 +250,7 @@ static const char milter_set_flags__doc__[] =
|
|||||||
Set flags for filter capabilities; OR of one or more of:\n\
|
Set flags for filter capabilities; OR of one or more of:\n\
|
||||||
ADDHDRS - filter may add headers\n\
|
ADDHDRS - filter may add headers\n\
|
||||||
CHGBODY - filter may replace body\n\
|
CHGBODY - filter may replace body\n\
|
||||||
CHGFROM - filter may replace body\n\
|
CHGFROM - filter may replace sender\n\
|
||||||
ADDRCPT - filter may add recipients\n\
|
ADDRCPT - filter may add recipients\n\
|
||||||
DELRCPT - filter may delete recipients\n\
|
DELRCPT - filter may delete recipients\n\
|
||||||
CHGHDRS - filter may change/delete headers";
|
CHGHDRS - filter may change/delete headers";
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ class sampleMilter(Milter.Milter):
|
|||||||
|
|
||||||
# even if we wanted the Taiwanese spam, we can't read Chinese
|
# even if we wanted the Taiwanese spam, we can't read Chinese
|
||||||
# (delete if you read chinese mail)
|
# (delete if you read chinese mail)
|
||||||
|
print('val=',val)
|
||||||
if val.startswith('=?big5') or val.startswith('=?ISO-2022-JP'):
|
if val.startswith('=?big5') or val.startswith('=?ISO-2022-JP'):
|
||||||
self.log('REJECT: %s: %s' % (name,val))
|
self.log('REJECT: %s: %s' % (name,val))
|
||||||
#self.setreply('550','','Go away spammer')
|
#self.setreply('550','','Go away spammer')
|
||||||
|
|||||||
Reference in New Issue
Block a user