Skip to content
Browse files

fix decode error when processing headers with an empty value

  • Loading branch information...
1 parent 58bf122 commit c29438ef7a0a933d11d068324c3f5fa2efb0a4b9 @flaviogrossi committed Jul 17, 2014
Showing with 7 additions and 4 deletions.
  1. +7 −4 txmilter/codec.py
View
11 txmilter/codec.py
@@ -271,8 +271,11 @@ def _decode_str(self, data):
def _decode_char(self, data):
return data
- def _decode_strs(self, data):
- return list(i for i in data.split('\0') if i)
+ def _decode_strs(self, data, ignore_emtpy=True):
+ if ignore_emtpy:
+ return list(i for i in data.split('\0') if i)
+ else:
+ return data.split('\0')
def _decode_u16(self, data):
try:
@@ -316,8 +319,8 @@ def _decode_smfic_helo_data(self, data):
return {'helo': self._decode_str(data)[0]}
def _decode_smfic_header_data(self, data):
- args = self._decode_strs(data)
- if len(args) != 2:
+ args = self._decode_strs(data, ignore_emtpy=False)
+ if len(args) < 2:
raise MilterCodecError('invalid data for header response')
return dict(name=args[0], value=args[1])

0 comments on commit c29438e

Please sign in to comment.
Something went wrong with that request. Please try again.