From fd85de9c3081decb1b665aa04e4314e2744448d1 Mon Sep 17 00:00:00 2001 From: Huub Bouma Date: Fri, 20 Sep 2013 16:28:05 +0200 Subject: [PATCH] Fix comments Title if utf-8 characters in author_name --- CHANGES.rst | 3 +++ plone/app/discussion/comment.py | 2 +- plone/app/discussion/tests/test_comment.py | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5d9f16f..5578e59 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,9 @@ Changelog - Fix ajax form submit for delete comment action: add 'data' to the request. [toutpt] +- Fix comments Title if utf-8 characters in author_name + [huub_bouma] + 2.2.8 (2013-08-20) ------------------ diff --git a/plone/app/discussion/comment.py b/plone/app/discussion/comment.py index df81bf7..6bcfdcf 100644 --- a/plone/app/discussion/comment.py +++ b/plone/app/discussion/comment.py @@ -186,7 +186,7 @@ class Comment(CatalogAware, WorkflowAware, DynamicType, Traversable, content = aq_base(self.__parent__.__parent__) title = translate( Message(COMMENT_TITLE, - mapping={'author_name': author_name, + mapping={'author_name': safe_unicode(author_name), 'content': safe_unicode(content.Title())})) return title diff --git a/plone/app/discussion/tests/test_comment.py b/plone/app/discussion/tests/test_comment.py index 1f39098..f0d5081 100644 --- a/plone/app/discussion/tests/test_comment.py +++ b/plone/app/discussion/tests/test_comment.py @@ -125,6 +125,18 @@ class CommentTest(unittest.TestCase): conversation.addComment(comment1) self.assertEqual(u"Tarek Ziadé on Document äüö", comment1.Title()) + def test_title_special_characters_utf8(self): + self.portal.invokeFactory( + id='doc_sp_chars_utf8', + title='Document ëïû', + type_name='Document' + ) + conversation = IConversation(self.portal.doc_sp_chars_utf8) + comment1 = createObject('plone.Comment') + comment1.author_name = "Hüüb Bôûmä" + conversation.addComment(comment1) + self.assertEqual(u"Hüüb Bôûmä on Document ëïû", comment1.Title()) + def test_creator(self): comment1 = createObject('plone.Comment') comment1.creator = "jim"