From e5cf24b2fd07db906fe5061b643655229b51f1ff Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Mon, 16 Sep 2013 12:44:50 -0400 Subject: [PATCH] Fully quote payload body contents in integrations (imported from commit 3cb03eabbd917f878b37aa226eb3f3ecda63d5e7) --- zerver/tests.py | 16 +++++++++++----- zerver/views/webhooks.py | 8 ++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/zerver/tests.py b/zerver/tests.py index 8ddb4848d5..979f508b9b 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -3111,7 +3111,9 @@ class JiraHookTests(AuthedTestCase): self.assertEqual(msg.content, """Leo Franchi **updated** [BUG-15](http://lfranchi.com:8080/browse/BUG-15): -> Adding a comment. Oh, what a comment it is!""") +~~~ quote +Adding a comment. Oh, what a comment it is! +~~~""") def test_deleted(self): msg = self.send_jira_message('deleted') @@ -3133,7 +3135,9 @@ class JiraHookTests(AuthedTestCase): * Changed status from **Resolved** to **Reopened** -> Re-opened yeah!""") +~~~ quote +Re-opened yeah! +~~~""") def test_resolved(self): msg = self.send_jira_message('resolved') @@ -3144,7 +3148,9 @@ class JiraHookTests(AuthedTestCase): * Changed status from **Open** to **Resolved** * Changed assignee from **None** to **Leo Franchi** -> Fixed it, finally!""") +~~~ quote +Fixed it, finally! +~~~""") def test_workflow_postfuncion(self): msg = self.send_jira_message('postfunction_hook') @@ -3328,7 +3334,7 @@ class PivotalHookTests(AuthedTestCase): msg = self.send_pivotal_message('created') self.assertEqual(msg.subject, 'My new Feature story') self.assertEqual(msg.content, 'Leo Franchi added "My new Feature story" \ -(unscheduled feature):\n\n> This is my long description\n\n \ +(unscheduled feature):\n\n~~~ quote\nThis is my long description\n~~~\n\n \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)') def test_delivered(self): @@ -3365,7 +3371,7 @@ class PivotalHookTests(AuthedTestCase): msg = self.send_pivotal_message('created_estimate') self.assertEqual(msg.subject, 'Another new story') self.assertEqual(msg.content, 'Leo Franchi added "Another new story" \ -(unscheduled feature worth 2 story points):\n\n> Some loong description\n\n \ +(unscheduled feature worth 2 story points):\n\n~~~ quote\nSome loong description\n~~~\n\n \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)') def test_type_changed(self): diff --git a/zerver/views/webhooks.py b/zerver/views/webhooks.py index 40c18722e2..20d8c6a6df 100644 --- a/zerver/views/webhooks.py +++ b/zerver/views/webhooks.py @@ -46,7 +46,7 @@ def api_github_landing(request, user_profile, event=REQ, subject = "%s: pull request %d" % (repository['name'], pull_req['number']) - content = ("Pull request from %s [%s](%s):\n\n %s\n\n> %s" + content = ("Pull request from %s [%s](%s):\n\n %s\n\n~~~ quote\n%s\n~~~" % (pull_req['user']['login'], payload['action'], pull_req['html_url'], @@ -79,7 +79,7 @@ def api_github_landing(request, user_profile, event=REQ, issue = payload['issue'] subject = "%s: issue %d %s" % (repository['name'], issue['number'], payload['action']) - content = ("%s %s [issue %d](%s): %s\n\n> %s" + content = ("%s %s [issue %d](%s): %s\n\n~~~ quote\n%s\n~~~" % (payload['sender']['login'], payload['action'], issue['number'], @@ -219,7 +219,7 @@ def api_jira_webhook(request): content += "* Changed %s from **%s** to **%s**\n" % (field, item.get('fromString'), item.get('toString')) if comment != '': - content += "\n> %s" % (comment,) + content += "\n~~~ quote\n%s\n~~~" % (comment,) elif 'transition' in payload: from_status = get_in(payload, ['transition', 'from_status']) to_status = get_in(payload, ['transition', 'to_status']) @@ -295,7 +295,7 @@ def api_pivotal_webhook(request): if estimate != '': estimate = " worth %s story points" % (estimate,) subject = name - content = "%s (%s %s%s):\n\n> %s\n\n%s" % (description, + content = "%s (%s %s%s):\n\n~~~ quote\n%s\n~~~\n\n%s" % (description, issue_status, issue_type, estimate,