Fix doco nit from qzrrbz@github

This commit is contained in:
Stuart D. Gathman
2020-06-02 15:08:21 -04:00
parent d5f9f86bba
commit bf3108b938
4 changed files with 12 additions and 5 deletions
+9 -3
View File
@@ -327,7 +327,9 @@ class Base(object):
# to pass bytes to @link #header the header callback @endlink instead,
# or trap utf-8 conversion exception, etc.
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)
## Called when the SMTP client says MAIL FROM. Called by the
# <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,
# or trap utf-8 conversion exception, etc.
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)
## Called when the SMTP client says RCPT TO. Called by the
# <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
# to pass bytes to @link #header the header callback @endlink instead.
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)
## Called for each header field in the message body.
# @param field name decoded as ascii
+1 -1
View File
@@ -234,7 +234,7 @@ class TestCtx(object):
else:
v = val.encode(encoding='ascii',errors='surrogateescape')
# invoke the Milter header_callback
return Milter.header_callback(self,fld,v)
return self._priv.header_bytes(fld,v)
def _eoh(self):
if self._protocol & Milter.P_NOEOH:
+1 -1
View File
@@ -250,7 +250,7 @@ static const char milter_set_flags__doc__[] =
Set flags for filter capabilities; OR of one or more of:\n\
ADDHDRS - filter may add headers\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\
DELRCPT - filter may delete recipients\n\
CHGHDRS - filter may change/delete headers";
+1
View File
@@ -73,6 +73,7 @@ class sampleMilter(Milter.Milter):
# even if we wanted the Taiwanese spam, we can't read Chinese
# (delete if you read chinese mail)
print('val=',val)
if val.startswith('=?big5') or val.startswith('=?ISO-2022-JP'):
self.log('REJECT: %s: %s' % (name,val))
#self.setreply('550','','Go away spammer')