[1.5.x] Added compatibility with legacy message length

Added compatibility code to not break when decoding messages
encoded on pre-1.5 versions.
Refs #19387. Thanks Florian Apolloner for noticing the issue.
This commit is contained in:
Claude Paroz 2012-12-21 13:36:22 +01:00
parent be10289d03
commit 9e7183073f
1 changed files with 3 additions and 0 deletions

View File

@ -33,6 +33,9 @@ class MessageDecoder(json.JSONDecoder):
def process_messages(self, obj):
if isinstance(obj, list) and obj:
if obj[0] == MessageEncoder.message_key:
if len(obj) == 3:
# Compatibility with previously-encoded messages
return Message(*obj[1:])
if obj[1]:
obj[3] = mark_safe(obj[3])
return Message(*obj[2:])