Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#4835 closed enhancement (invalid)

fix for bad contrib/emailfilter.py encoding behaviour

Reported by: jodok@… Owned by: Jonas Borgström
Priority: normal Milestone:
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Emmanuel Blot)

when submitting tickets via e-mail using the emailfilter.py, it caused trac to crash. the reason was that it inserted non-utf8 content into the database. the attached diff should fix that:

@@ -53,7 +53,10 @@
         tkt['summary'] = msg['subject']
         for part in msg.walk():
             if part.get_content_type() == 'text/plain':
-                tkt['description'] = part.get_payload(decode=1).strip()
+                ch = part.get_content_charset()
+                payload = part.get_payload(decode=True).strip()
+                plain = unicode(payload, ch).encode('utf-8')
+                tkt['description'] = plain
 
         if tkt.values.get('description'):
             tkt.insert()

Attachments (0)

Change History (3)

comment:1 by jodok@…, 18 years ago

sorry, we can use WikiFormatting :)

@@ -53,7 +53,10 @@
         tkt['summary'] = msg['subject']
         for part in msg.walk():
             if part.get_content_type() == 'text/plain':
-                tkt['description'] = part.get_payload(decode=1).strip()
+                ch = part.get_content_charset()
+                payload = part.get_payload(decode=True).strip()
+                plain = unicode(payload, ch).encode('utf-8')
+                tkt['description'] = plain
 
         if tkt.values.get('description'):
             tkt.insert()

comment:2 by Emmanuel Blot, 18 years ago

Description: modified (diff)

This web site is for the development of Trac itself.

Please report any plugin/extension issue to their respective author: th:wiki:EmailtoTracScript

Thanks in advance.

comment:3 by Emmanuel Blot, 18 years ago

Resolution: invalid
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.