Modify ↓
Opened 8 years ago
Closed 8 years ago
#13335 closed defect (duplicate)
Non-ASCII characters in messages are handled incorrectly
| Reported by: | 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 8 years ago by
comment:2 Changed 8 years ago by
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Is this still a problem with the latest version of the plugin? It seems like a duplicate of #13196. Please reopen otherwise.
Note: See
TracTickets for help on using
tickets.



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) --