Skip to content
Snippets Groups Projects
Commit c9e32e4b authored by Stuart Gathman's avatar Stuart Gathman
Browse files

throw ValueError when message line contains a single %

parent 83a17625
No related branches found
No related tags found
No related merge requests found
...@@ -374,8 +374,16 @@ class Base(object): ...@@ -374,8 +374,16 @@ class Base(object):
## Set the SMTP reply code and message. ## Set the SMTP reply code and message.
# If the MTA does not support setmlreply, then only the # If the MTA does not support setmlreply, then only the
# first msg line is used. # first msg line is used. Any '%' in a message line
# must be doubled, or libmilter will silently ignore the setreply.
# Beginning with 0.9.6, we test for that case and throw ValueError to avoid
# head scratching. What will <i>really</i> irritate you, however,
# is that if you carefully double any '%', your message will be
# sent - but with the '%' still doubled!
def setreply(self,rcode,xcode=None,msg=None,*ml): def setreply(self,rcode,xcode=None,msg=None,*ml):
for m in (msg,)+ml:
if 1 in [len(s)&1 for s in R.findall(m)]:
raise ValueError("'%' must be doubled: "+m)
return self._ctx.setreply(rcode,xcode,msg,*ml) return self._ctx.setreply(rcode,xcode,msg,*ml)
## Tell the MTA which macro names will be used. ## Tell the MTA which macro names will be used.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment