Index: /emailtotracscript/trunk/ChangeLog
===================================================================
--- /emailtotracscript/trunk/ChangeLog	(revision 138)
+++ /emailtotracscript/trunk/ChangeLog	(revision 139)
@@ -1,7 +1,19 @@
 2XXXXXX
 	* email2trac.py:
-	
 	  - Added verbatim_format option default is: 1
+	  Added by : Bas van der Vlies
+
 	  - Added strip_signature option default is: 0 
+	  Added by : Bas van der Vlies
+
+	  - Fixed some unicode errors, thanks to japanes SPAM. 
+	    If we can not unicode email message then display which
+	    charset must be installed in ticket description. Else we 
+	    trac crashed with unicode errors ;-(
+	  Fixed by: Bas van der Vlies
+
+	* delete_spam.py:
+	  - Now works for version 0.10 with new API-functions
+	  Fixed by: Bas van der Vlies
 
 2006-10-27
Index: /emailtotracscript/trunk/debian/changelog
===================================================================
--- /emailtotracscript/trunk/debian/changelog	(revision 138)
+++ /emailtotracscript/trunk/debian/changelog	(revision 139)
@@ -1,2 +1,8 @@
+email2trac (0.8.2-2) stable; urgency=low
+
+  * Try new version with unicode fixes 
+
+ -- root <root@subtrac.sara.nl>  Mon,  4 Dec 2006 12:04:30 +0100
+
 email2trac (0.8.2-1) stable; urgency=low
 
Index: /emailtotracscript/trunk/email2trac.py.in
===================================================================
--- /emailtotracscript/trunk/email2trac.py.in	(revision 138)
+++ /emailtotracscript/trunk/email2trac.py.in	(revision 139)
@@ -182,5 +182,4 @@
 			self.STRIP_SIGNATURE = 0
 
-
 	# X-Spam-Score: *** (3.255) BAYES_50,DNS_FROM_AHBL_RHSBL,HTML_
 	# Note if Spam_level then '*' are included
@@ -198,5 +197,5 @@
 		return self.get_config('ticket', 'default_component') 
 
-	def to_unicode(self, str):
+	def email_to_unicode(self, message_str):
 		"""
 		Email has 7 bit ASCII code, convert it to unicode with the charset
@@ -204,5 +203,5 @@
 		understands it.
 		"""
-		results =  email.Header.decode_header(str)
+		results =  email.Header.decode_header(message_str)
 		str = None
 		for text,format in results:
@@ -210,8 +209,13 @@
 				try:
 					temp = unicode(text, format)
-				except (UnicodeError,LookupError):
+				except UnicodeError, detail:
 					# This always works 
 					#
 					temp = unicode(text, 'iso-8859-15')
+				except LookupError, detail:
+					#text = 'ERROR: Could not find charset: %s, please install' %format
+					#temp = unicode(text, 'iso-8859-15')
+					temp = message_str
+				    	
 			else:
 				temp = string.strip(text)
@@ -223,5 +227,5 @@
 				str = '%s' %temp
 
-		str = str.encode('utf-8')
+		#str = str.encode('utf-8')
 		return str
 
@@ -267,6 +271,5 @@
 			str = "%s'''Cc:''' %s [[BR]]" % (str, m['Cc'])
 
-		#return  self.to_unicode(str)
-		return  util.text.to_unicode(str)
+		return  self.email_to_unicode(str)
 
 
@@ -300,6 +303,5 @@
 			self.email_field = users[0]
 		else:
-			#self.email_field =  self.to_unicode(message['from'])
-			self.email_field =  util.text.to_unicode(message['from'])
+			self.email_field =  self.email_to_unicode(message['from'])
 
 	def set_reply_fields(self, ticket, message):
@@ -335,6 +337,5 @@
 
 			if mail_list:
-				#ticket['cc'] = self.to_unicode(mail_list)
-				ticket['cc'] = util.text.to_unicode(mail_list)
+				ticket['cc'] = self.email_to_unicode(mail_list)
 
 	def save_email_for_debug(self, message, tempfile=False):
@@ -362,6 +363,5 @@
 			return False
 		else:
-			#subject  = self.to_unicode(m['Subject'])
-			subject  = util.text.to_unicode(m['Subject'])
+			subject  = self.email_to_unicode(m['Subject'])
 
 		TICKET_RE = re.compile(r"""
@@ -423,6 +423,5 @@
 			tkt['summary'] = u'(geen subject)'
 		else:
-			#tkt['summary'] = self.to_unicode(msg['Subject'])
-			tkt['summary'] = util.text.to_unicode(msg['Subject'])
+			tkt['summary'] = self.email_to_unicode(msg['Subject'])
 
 
@@ -470,7 +469,5 @@
 			changed = True
 			comment = '\nadded mailto line\n'
-			#mailto = self.html_mailto_link(self.to_unicode(msg['subject']), ticket_id, body_text)
-			mailto = self.html_mailto_link(util.text.to_unicode(msg['subject']), ticket_id, body_text)
-			#tkt['description'] = 'email2trac:%s%s\r\n{{{\r\n%s\r\n}}}' %(head, mailto, body_text)
+			mailto = self.html_mailto_link(self.email_to_unicode(msg['subject']), ticket_id, body_text)
 			tkt['description'] = 'email2trac:%s%s\r\n%s' %(head, mailto, body_text)
 
@@ -569,6 +566,5 @@
 
 				except LookupError, detail:
-					ubody_text = body_text
-					encoding = False
+					ubody_text = 'ERROR: Could not find charset: %s, please install' %(charset)
 
 			elif part.get_content_type() == 'text/html':
@@ -632,6 +628,5 @@
 			author = self.email_addr
 		else:	
-			#author = self.to_unicode(self.author)
-			author = util.text.to_unicode(self.author)
+			author = self.email_to_unicode(self.author)
 
 		# Must find a fix
@@ -681,6 +676,5 @@
 				filename = '%s%s' % (filename, ext)
 			else:
-				#filename = self.to_unicode(filename)
-				filename = util.text.to_unicode(filename)
+				filename = self.email_to_unicode(filename)
 
 			# From the trac code
@@ -746,6 +740,5 @@
 				if not update:
 					att.author = self.author
-					#att.description = self.to_unicode('Added by email2trac')
-					att.description = util.text.to_unicode('Added by email2trac')
+					att.description = self.email_to_unicode('Added by email2trac')
 
 				att.insert(url_filename, fd, filesize)
@@ -877,4 +870,7 @@
 			from trac.web.href import Href
 			from trac import util
+			#
+			# return  util.text.to_unicode(str)
+			#
 			# see http://projects.edgewall.com/trac/changeset/2799
 			from trac.ticket.notification import TicketNotifyEmail
