[Spambayes-checkins] spambayes/spambayes/test test_sb_server.py, 1.2, 1.3

Tony Meyer anadelonbrin at users.sourceforge.net
Mon Nov 29 01:11:50 CET 2004


Update of /cvsroot/spambayes/spambayes/spambayes/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6041/spambayes/test

Modified Files:
	test_sb_server.py 
Log Message:
Fix error reported by Hatuka*nezumi:

Messages that did not have the required \r?\n\r?\n separator would just pass through
 spambayes unproxied.  Change this so that they are (everything will be a header,
 though, so it may not proxy well, and might generate and exception header - but that's
 better than just letting it through.

Index: test_sb_server.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/test/test_sb_server.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_sb_server.py	9 Nov 2004 02:37:41 -0000	1.2
--- test_sb_server.py	29 Nov 2004 00:11:47 -0000	1.3
***************
*** 77,80 ****
--- 77,83 ----
  """
  
+ malformed1 = """From: ta-meyer at ihug.co.nz
+ Subject: No body, and no separator"""
+ 
  import asyncore
  import socket
***************
*** 123,127 ****
          Dibbler.BrighterAsyncChat.__init__(self, map=socketMap)
          Dibbler.BrighterAsyncChat.set_socket(self, clientSocket, socketMap)
!         self.maildrop = [spam1, good1]
          self.set_terminator('\r\n')
          self.okCommands = ['USER', 'PASS', 'APOP', 'NOOP', 'SLOW',
--- 126,130 ----
          Dibbler.BrighterAsyncChat.__init__(self, map=socketMap)
          Dibbler.BrighterAsyncChat.set_socket(self, clientSocket, socketMap)
!         self.maildrop = [spam1, good1, malformed1]
          self.set_terminator('\r\n')
          self.okCommands = ['USER', 'PASS', 'APOP', 'NOOP', 'SLOW',
***************
*** 219,223 ****
          if 0 < number <= len(self.maildrop):
              message = self.maildrop[number-1]
!             headers, body = message.split('\n\n', 1)
              bodyLines = body.split('\n')[:maxLines]
              message = headers + '\r\n\r\n' + '\n'.join(bodyLines)
--- 222,229 ----
          if 0 < number <= len(self.maildrop):
              message = self.maildrop[number-1]
!             try:
!                 headers, body = message.split('\n\n', 1)
!             except ValueError:
!                 return "+OK\r\n%s\r\n.\r\n" % message
              bodyLines = body.split('\n')[:maxLines]
              message = headers + '\r\n\r\n' + '\n'.join(bodyLines)
***************
*** 314,318 ****
      response = proxy.recv(100)
      count, totalSize = map(int, response.split()[1:3])
!     assert count == 2
  
      # Loop through the messages ensuring that they have judgement
--- 320,324 ----
      response = proxy.recv(100)
      count, totalSize = map(int, response.split()[1:3])
!     assert count == 3
  
      # Loop through the messages ensuring that they have judgement



More information about the Spambayes-checkins mailing list