Modify

Opened 13 years ago

Closed 13 years ago

#63 closed defect (fixed)

Crash when parsing X-Spam-Score headers with no score

Reported by: email2trac@… Owned by: bas
Priority: major Milestone:
Component: email2trac Version: 0.13
Keywords: Cc:

Description

Given a non-spam email, i.e. the X-Spam-Score header is present, but has no value, the script will crash with:

Traceback (most recent call last):
  File "/usr/bin/email2trac", line 1137, in ?     tktparser.parse(sys.stdin)
  File "/usr/bin/email2trac", line 710, in parse     component =  self.spam(m)
  File "/usr/bin/email2trac", line 245, in spam     number = spam_l[0].count('*')
IndexError: list index out of range

Patch as follows:

--- email2trac.orig     2008-05-29 15:02:15.000000000 -0700
+++ email2trac  2008-05-29 15:04:09.000000000 -0700
@@ -242,7 +242,10 @@
                spam = False
                if message.has_key('X-Spam-Score'):
                        spam_l = string.split(message['X-Spam-Score'])
-                       number = spam_l[0].count('*')
+                       if len(spam_l) == 0:
+                               number = 0
+                       else:
+                               number = spam_l[0].count('*')
 
                        if number >= self.SPAM_LEVEL:
                                spam = True

Attachments (0)

Change History (2)

comment:1 Changed 13 years ago by bas

  • Status changed from new to assigned

thanks for the patch, it is aplied to trunk

comment:2 Changed 13 years ago by bas

  • Resolution set to fixed
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Change Properties
Action
as closed The owner will remain bas.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.