diff --git a/Milter/__init__.py b/Milter/__init__.py
index 542be0b..7e09328 100755
--- a/Milter/__init__.py
+++ b/Milter/__init__.py
@@ -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
#
@@ -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
#
@@ -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
diff --git a/Milter/testctx.py b/Milter/testctx.py
index 4225615..7235694 100644
--- a/Milter/testctx.py
+++ b/Milter/testctx.py
@@ -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:
diff --git a/miltermodule.c b/miltermodule.c
index f7422e2..07708ef 100644
--- a/miltermodule.c
+++ b/miltermodule.c
@@ -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";
diff --git a/sample.py b/sample.py
index 9565591..031c22d 100644
--- a/sample.py
+++ b/sample.py
@@ -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')