allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [09/50] [abbrv] git commit: [#5693] ticket:382 added empty line in discussion footer because paragraph processed by Markdown as a header
Date Thu, 11 Jul 2013 21:58:29 GMT
[#5693]  ticket:382 added empty line in  discussion footer because paragraph processed by Markdown
as a header


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2b6444d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2b6444d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2b6444d4

Branch: refs/heads/db/6277
Commit: 2b6444d4b22bf203fa5c88e49c043d0fd5ec8287
Parents: ebc7e43
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Fri Jun 28 12:49:33 2013 +0400
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Jul 3 16:46:33 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/mail_tasks.py               |  4 +++-
 Allura/allura/templates/mail/Discussion.txt     |  2 ++
 Allura/allura/templates/mail/Ticket.txt         |  2 +-
 .../tests/functional/test_forum.py              |  1 +
 .../forgetracker/tests/functional/test_root.py  | 25 ++++++++++++++++++++
 5 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2b6444d4/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 6526987..c949497 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -16,6 +16,7 @@
 #       under the License.
 
 import logging
+import HTMLParser
 
 from pylons import tmpl_context as c, app_globals as g
 from bson import ObjectId
@@ -118,7 +119,8 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
                 addrs_html.append(addr)
             else:
                 addrs_multi.append(addr)
-    plain_msg = mail_util.encode_email_part(text, 'plain')
+    htmlparser = HTMLParser.HTMLParser()
+    plain_msg = mail_util.encode_email_part(htmlparser.unescape(text), 'plain')
     html_text = g.forge_markdown(email=True).convert(text)
     html_msg = mail_util.encode_email_part(html_text, 'html')
     multi_msg = mail_util.make_multipart_message(plain_msg, html_msg)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2b6444d4/Allura/allura/templates/mail/Discussion.txt
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/Discussion.txt b/Allura/allura/templates/mail/Discussion.txt
index cab33d2..4702f21 100644
--- a/Allura/allura/templates/mail/Discussion.txt
+++ b/Allura/allura/templates/mail/Discussion.txt
@@ -17,5 +17,7 @@
        under the License.
 #}
 
+
 ---
+
 [{{post.thread.subject}}]({{h.absurl(post.url_paginated())}})

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2b6444d4/Allura/allura/templates/mail/Ticket.txt
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/Ticket.txt b/Allura/allura/templates/mail/Ticket.txt
index 78ffc00..7c4c4da 100644
--- a/Allura/allura/templates/mail/Ticket.txt
+++ b/Allura/allura/templates/mail/Ticket.txt
@@ -20,7 +20,7 @@
 
 ---
 
-** [{{data.app_config.options.mount_point}}:#{{data.ticket_num}}] {{data.summary}}**
+** [{{data.app_config.options.mount_point}}:#{{data.ticket_num}}] {{data.summary|e}}**
 
 **Status:** {{data.status}}
 {% if data.labels.__len__() -%}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2b6444d4/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index c9f7196..ffa0ca1 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -403,6 +403,7 @@ class TestForum(TestController):
         n = M.Notification.query.get(subject='[test:discussion] Test Thread')
         post = FM.ForumPost.query.get(text='This is a *test thread*')
         assert post.url_paginated() in n.text
+        assert 'This is a *test thread*\n\n\n---\n\n[Test Thread]' in n.text
         assert '[Test Thread](' in n.text
         assert 'noreply' not in n.reply_to_address, n
         assert 'testforum@discussion.test.p' in n.reply_to_address, n

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2b6444d4/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 2e14fff..77e0dc7 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -23,6 +23,7 @@ import time
 import json
 import StringIO
 import allura
+import mock
 
 import PIL
 from mock import patch
@@ -40,6 +41,7 @@ from allura.lib.security import has_access
 from allura.lib import helpers as h
 from allura.lib.search import SearchError
 from allura.tests import decorators as td
+from allura.tasks import  mail_tasks
 from ming.orm.ormsession import ThreadLocalORMSession
 
 class TrackerTestController(TestController):
@@ -1879,6 +1881,29 @@ class TestFunctionalController(TrackerTestController):
         r = json.loads(r.body)
         assert_equal(r['ticket']['attachments'][0]['url'], 'http://localhost:80/p/test/bugs/1/attachment/test_root.py')
 
+    def test_html_escaping(self):
+        with mock.patch.object(mail_tasks.smtp_client, '_client') as _client:
+            self.new_ticket(summary='test <h2> ticket', status='open', _milestone='2.0')
+            ThreadLocalORMSession.flush_all()
+            M.MonQTask.run_ready()
+            ThreadLocalORMSession.flush_all()
+            email = M.MonQTask.query.find(dict(task_name='allura.tasks.mail_tasks.sendmail')).first()
+            assert_equal(email.kwargs.subject, '[test:bugs] #1 test <h2> ticket')
+            text = email.kwargs.text
+            assert '** [bugs:#1] test &lt;h2&gt; ticket**' in text
+            mail_tasks.sendmail(
+                fromaddr=str(c.user._id),
+                destinations=[ str(c.user._id) ],
+                text=text,
+                reply_to=u'noreply@sf.net',
+                subject=email.kwargs.subject,
+                message_id=h.gen_message_id())
+            assert_equal(_client.sendmail.call_count, 1)
+            return_path, rcpts, body = _client.sendmail.call_args[0]
+            body = body.split('\n')
+            assert 'Subject: [test:bugs] #1 test <h2> ticket' in body
+            assert '<p><strong> <a class="alink" href="http://localhost/p/test/bugs/1/">[bugs:#1]</a>
test &lt;h2&gt; ticket</strong></p>' in body
+
 
 
 class TestMilestoneAdmin(TrackerTestController):


Mime
View raw message