[Spambayes-checkins] spambayes pop3proxy.py,1.88,1.89

Richie Hindle richiehindle at users.sourceforge.net
Mon Jul 28 14:13:57 EDT 2003


Update of /cvsroot/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv17601

Modified Files:
	pop3proxy.py 
Log Message:
Made the pop3proxy work with fetchmail, which uses "TOP N 99999999"
instead of "RETR N" to retrieve messages.

When proxying a single-message LIST command, add the header-size
fudge factor to the message size rather than the message number (must
have been a Friday afternoon...)


Index: pop3proxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/pop3proxy.py,v
retrieving revision 1.88
retrieving revision 1.89
diff -C2 -d -r1.88 -r1.89
*** pop3proxy.py	19 Jul 2003 09:15:00 -0000	1.88
--- pop3proxy.py	28 Jul 2003 20:13:55 -0000	1.89
***************
*** 172,176 ****
          self.set_terminator('\r\n')
          self.command = ''           # The POP3 command being processed...
!         self.args = ''              # ...and its arguments
          self.isClosing = False      # Has the server closed the socket?
          self.seenAllHeaders = False # For the current RETR or TOP
--- 172,176 ----
          self.set_terminator('\r\n')
          self.command = ''           # The POP3 command being processed...
!         self.args = []              # ...and its arguments
          self.isClosing = False      # Has the server closed the socket?
          self.seenAllHeaders = False # For the current RETR or TOP
***************
*** 254,261 ****
          if self.request.strip() == '':
              # Someone just hit the Enter key.
!             self.command = self.args = ''
          else:
              # A proper command.
!             splitCommand = self.request.strip().split(None, 1)
              self.command = splitCommand[0].upper()
              self.args = splitCommand[1:]
--- 254,262 ----
          if self.request.strip() == '':
              # Someone just hit the Enter key.
!             self.command = ''
!             self.args = []
          else:
              # A proper command.
!             splitCommand = self.request.strip().split()
              self.command = splitCommand[0].upper()
              self.args = splitCommand[1:]
***************
*** 284,288 ****
          # Reset.
          self.command = ''
!         self.args = ''
          self.isClosing = False
          self.seenAllHeaders = False
--- 285,289 ----
          # Reset.
          self.command = ''
!         self.args = []
          self.isClosing = False
          self.seenAllHeaders = False
***************
*** 396,400 ****
              outputLines = [lines[0]]
              for line in lines[1:]:
!                 match = re.search('^(\d+)\s+(\d+)', line)
                  if match:
                      number = int(match.group(1))
--- 397,401 ----
              outputLines = [lines[0]]
              for line in lines[1:]:
!                 match = re.search(r'^(\d+)\s+(\d+)', line)
                  if match:
                      number = int(match.group(1))
***************
*** 405,412 ****
          else:
              # Single line.
!             match = re.search('^\+OK\s+(\d+)(.*)\r\n', response)
              if match:
!                 size = int(match.group(1)) + HEADER_SIZE_FUDGE_FACTOR
!                 return "+OK %d%s\r\n" % (size, match.group(2))
              else:
                  return response
--- 406,415 ----
          else:
              # Single line.
!             match = re.search(r'^\+OK\s+(\d+)\s+(\d+)(.*)\r\n', response)
              if match:
!                 messageNumber = match.group(1)
!                 size = int(match.group(2)) + HEADER_SIZE_FUDGE_FACTOR
!                 trailer = match.group(3)
!                 return "+OK %s %s%s\r\n" % (messageNumber, size, trailer)
              else:
                  return response
***************
*** 437,441 ****
                  msg.addSBHeaders(prob, clues)
  
!                 if command == 'RETR':
                      cls = msg.GetClassification()
                      if cls == options["Hammie", "header_ham_string"]:
--- 440,448 ----
                  msg.addSBHeaders(prob, clues)
  
!                 # Check for "RETR" or "TOP N 99999999" - fetchmail without
!                 # the 'fetchall' option uses the latter to retrieve messages.
!                 if (command == 'RETR' or
!                     (command == 'TOP' and
!                      len(args) == 2 and args[1] == '99999999')):
                      cls = msg.GetClassification()
                      if cls == options["Hammie", "header_ham_string"]:





More information about the Spambayes-checkins mailing list