Modify

Opened 6 years ago

Closed 6 years ago

#13335 closed defect (duplicate)

Non-ASCII characters in messages are handled incorrectly

Reported by: f.poloni@… Owned by: Peter Suter
Priority: low Component: OnSiteNotificationsPlugin
Severity: minor Keywords: unicode
Cc: f.poloni@… Trac Release: 1.2

Description

The plugin fails to send notifications in the case when the ticket summary contains non-ASCII characters.

INotificationFormatter.format produces a bytestring (because it is meant to be sent via e-mail, I presume), which cannot be inserted into the database directly (and the DB insertion in OnSiteMessage.add fails).

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by anonymous

Quick fix:

--- a/plugins-source/onsitenotificationsplugin/onsitenotifications/model.py
+++ b/plugins-source/onsitenotificationsplugin/onsitenotifications/model.py
@@ -45,7 +45,12 @@ class OnSiteMessage(object):
 
     @classmethod
     def add(cls, env, sid, authenticated, message, realm, target):
-        with env.db_transaction as db:
+    	# message is a str (because it is meant to be sent as e-mail)
+    	# but it may contain unicode characters, so we need to convert it
+    	# to the proper encoding before inserting it into the db
+    	if isinstance(message, str):
+    		message = message.decode('utf-8')
+    	with env.db_transaction as db:
             db("""
                 INSERT INTO onsitenotification (sid, authenticated, message,
                                                 realm, target)
-- 

comment:2 Changed 6 years ago by Peter Suter

Resolution: duplicate
Status: newclosed

Is this still a problem with the latest version of the plugin? It seems like a duplicate of #13196. Please reopen otherwise.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.