diff options
author | W. Trevor King <wking@drexel.edu> | 2009-10-20 09:38:17 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-10-20 09:38:17 -0400 |
commit | c80312557917015fcda9f7baa9e1acdce8ad9de7 (patch) | |
tree | a12410e78c028ce2b6cd1d880e860fb843e280c7 /libbe | |
parent | a808d2f4f0d91c049da826480f9d0fe7f0848b1c (diff) | |
parent | 74864cbce9ded7764e05647d5433fc7c9958e22a (diff) | |
download | bugseverywhere-c80312557917015fcda9f7baa9e1acdce8ad9de7.tar.gz |
Merged my cleanup of Gianluca's HTML branch.
This fixes a bug in binary comments (non-"text/" content-types), where
the content-type wasn't being set until _after_ the save was
attempted. This led to errors for non-ascii bodies (e.g. images with
null characters).
Note that text/html comments are included as is, so make sure they are
formatted appropriately to fit into your tempate without creating
invalid code. This issue could be a real pain in the neck, especially
when including text/html email bodies, which might contain <body>
tags, etc.. Stupid email clients that don't send a text/plain
alternative...
Diffstat (limited to 'libbe')
-rw-r--r-- | libbe/comment.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libbe/comment.py b/libbe/comment.py index 41bc7e6..02bcc93 100644 --- a/libbe/comment.py +++ b/libbe/comment.py @@ -604,7 +604,7 @@ class Comment(Tree, settings_object.SavedSettingsObject): reply.in_reply_to = self.uuid self.append(reply) - def new_reply(self, body=None): + def new_reply(self, body=None, content_type=None): """ >>> comm = Comment(bug=None, body="Some insightful remarks") >>> repA = comm.new_reply("Critique original comment") @@ -613,6 +613,8 @@ class Comment(Tree, settings_object.SavedSettingsObject): True """ reply = Comment(self.bug, body=body) + if content_type != None: # set before saving body to decide binary format + reply.content_type = content_type if self.bug != None: reply.set_sync_with_disk(self.bug.sync_with_disk) if reply.sync_with_disk == True: |