django.contrib.messages failing silently in safari when comma is used in message

21 views
Skip to first unread message

Sean Brant

unread,
Dec 30, 2009, 9:10:18 PM12/30/09
to Django developers
If you try and send a message with new messaging app that contains a
comma in the message it does not work in Safari.

I'm not really sure why the json encoded message is not working in the
Safari browser, but I fixed it by adding a base64 encode and decode
step that encodes/decodes the message string.

def _encode(self, messages, encode_empty=False):
...
if messages or encode_empty:
for message in messages:
message.message = base64.b64encode(message.message)
encoder = MessageEncoder(separators=(',', ':'))
...

def _decode(self, data):
...
messages = json.loads(value, cls=MessageDecoder)
for message in messages:
message.message = base64.b64decode
(message.message)
return messages
except ValueError:
pass
...

Sean Brant

unread,
Dec 30, 2009, 9:12:03 PM12/30/09
to Django developers
Sorry should note, this happens when using the CookieStorage backend.

Sean Brant

unread,
Dec 30, 2009, 9:23:29 PM12/30/09
to Django developers
I created a ticket for this http://code.djangoproject.com/ticket/12470
in case someone wants it.
Reply all
Reply to author
Forward
0 new messages