diff --git a/CHANGES.txt b/CHANGES.txt index e77e101..c83a9d5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,10 @@ Changelog 2.2.1 (unreleased) ------------------ +- Make conversation view not break when comment-id cannot be converted to long. + Fixes #13327 + [khink] + - fix insufficient privileges when trying to view the RSS feed of a comment collection [maartenkling] diff --git a/plone/app/discussion/conversation.py b/plone/app/discussion/conversation.py index 2d870fe..ec2520c 100644 --- a/plone/app/discussion/conversation.py +++ b/plone/app/discussion/conversation.py @@ -210,7 +210,11 @@ class Conversation(Traversable, Persistent, Explicit): def __getitem__(self, key): """Get an item by its long key """ - return self._comments[long(key)].__of__(self) + try: + comment_id = long(key) + except ValueError: + return + return self._comments[comment_id].__of__(self) def __delitem__(self, key, suppress_container_modified=False): """Delete an item by its long key diff --git a/plone/app/discussion/tests/test_conversation.py b/plone/app/discussion/tests/test_conversation.py index 76babf9..a424a28 100644 --- a/plone/app/discussion/tests/test_conversation.py +++ b/plone/app/discussion/tests/test_conversation.py @@ -699,6 +699,14 @@ class ConversationTest(unittest.TestCase): self.assertEqual('http://nohost/plone/doc1/++conversation++default', conversation.absolute_url()) + def test_unconvertible_id(self): + # make sure the conversation view doesn't break when given comment id + # can't be converted to long + + conversation = self.portal.doc1.restrictedTraverse( + '++conversation++default/ThisCantBeRight') + self.assertEqual(conversation, None) + def test_parent(self): # Check that conversation has a content object as parent diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index 25730b0..0c7f31e 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -20,7 +20,7 @@ optionflags = ( doctest.REPORT_ONLY_FIRST_FAILURE) normal_testfiles = [ 'functional_test_comments.txt', - 'functional_test_comment_review_workflow.txt' + 'functional_test_comment_review_workflow.txt', ]