diff --git a/CHANGES.txt b/CHANGES.txt index 41e0355..649d2ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,19 @@ Changelog 2.0b1 (Unreleased) ------------------ +- Use the cooked text of legacy comments when migrating. + [davisagli] + +- Make sure that comment text is transformed to plain text when indexing. + [davisagli] + +- Move logic for transforming comment text to the Comment class's getText + method. Use a comment instance's mime_type attribute in preference to the + global setting for the source mimetype. Use text/x-html-safe as the target + mimetype to make sure the safe HTML filter is applied, in case the source is + untrusted HTML. + [davisagli] + - Provide a filter_callback option to the migration view, so that a custom policy for which comments get migrated can be implemented. [davisagli] diff --git a/plone/app/discussion/browser/comments.pt b/plone/app/discussion/browser/comments.pt index 0ddca97..8cc2f3a 100644 --- a/plone/app/discussion/browser/comments.pt +++ b/plone/app/discussion/browser/comments.pt @@ -80,7 +80,7 @@
First paragraph
") + + def test_getText_escapes_HTML(self): + comment1 = createObject('plone.Comment') + comment1.text = """Got HTML?""" + self.assertEquals(comment1.getText(), + "Second paragraph
<b>Got HTML?</b>
") + + def test_getText_with_non_ascii_characters(self): + comment1 = createObject('plone.Comment') + comment1.text = u"""Umlaute sind ä, ö und ü.""" + self.assertEquals(comment1.getText(), + 'Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.
') + + def test_getText_doesnt_link(self): + comment1 = createObject('plone.Comment') + comment1.text = "Go to http://www.plone.org" + self.assertEquals(comment1.getText(), + "Go to http://www.plone.org
") + + def test_getText_uses_comment_mime_type(self): + comment1 = createObject('plone.Comment') + comment1.text = "Go to http://www.plone.org" + comment1.mime_type = 'text/x-web-intelligent' + self.assertEquals(comment1.getText(), + 'Go to http://www.plone.org') + + def test_getText_w_custom_targetMimetype(self): + comment1 = createObject('plone.Comment') + comment1.text = 'para' + self.assertEquals(comment1.getText(targetMimetype='text/plain'), 'para') + def test_traversal(self): # make sure comments are traversable, have an id, absolute_url and # physical path diff --git a/plone/app/discussion/tests/test_comments_viewlet.py b/plone/app/discussion/tests/test_comments_viewlet.py index a7ef15d..d5a0f21 100644 --- a/plone/app/discussion/tests/test_comments_viewlet.py +++ b/plone/app/discussion/tests/test_comments_viewlet.py @@ -228,28 +228,6 @@ class TestCommentsViewlet(PloneTestCase): settings = registry.forInterface(IDiscussionSettings) settings.globally_enabled = True - def test_cook(self): - text = """First paragraph - - Second paragraph""" - self.assertEquals(self.viewlet.cook(text), - "First paragraph
") - - def test_cook_no_html(self): - text = """Got HTML?""" - self.assertEquals(self.viewlet.cook(text), - "Second paragraph
<b>Got HTML?</b>
") - - def test_cook_with_no_ascii_characters(self): - text = """Umlaute sind ä, ö und ü.""" - self.assertEquals(self.viewlet.cook(text), - "Umlaute sind \xc3\xa4, \xc3\xb6 und \xc3\xbc.
") - - def test_cook_links(self): - text = "Go to http://www.plone.org" - self.assertEquals(self.viewlet.cook(text), - "Go to http://www.plone.org
") - def test_can_reply(self): # Portal owner can reply self.failUnless(self.viewlet.can_reply()) diff --git a/plone/app/discussion/tests/test_migration.py b/plone/app/discussion/tests/test_migration.py index d9bd8d3..8df9e16 100644 --- a/plone/app/discussion/tests/test_migration.py +++ b/plone/app/discussion/tests/test_migration.py @@ -69,7 +69,8 @@ class MigrationTest(PloneTestCase): comment1 = conversation.values()[0] self.assert_(IComment.providedBy(comment1)) self.assertEquals(comment1.Title(), 'Jim on Document 1') - self.assertEquals(comment1.text, 'My Text') + self.assertEquals(comment1.text, 'My Text
\n') + self.assertEquals(comment1.mime_type, 'text/html') self.assertEquals(comment1.Creator(), 'Jim') self.assertEquals(comment1.creation_date, datetime(2003, 3, 11, 9, 28, 6))