webhooks/freshdesk/doc.md: Render example JSON correctly.

We've been getting reports from users that our Freshdesk webhook
isn't working correctly. It turns out that the issue had nothing
to do with the webhook implementation itself!

In freshdesk/doc.md, we have a JSON template we ask users to
copy/paste into a textbox in the Freshdesk UI. That JSON template
contains "{{" and "}}" characters which we escaped as Unicode
decimals to prevent clashes with Jinja2 syntax in other parts
of the same template. This worked for a while!

But thanks to the changes introduced as part of the
nested_code_blocks extension, such escaped characters were never
decoded, leading users to copy/paste the same template but with
raw escaped unicode representations of "{{" and "}}" inside. And
that eventually broke our webhook implementation.

This commit makes sure that such characters are properly "unescaped",
just for Freshdesk docs.
This commit is contained in:
Eeshan Garg
2018-08-14 17:57:03 -02:30
committed by Tim Abbott
parent b3a8790c59
commit f476ec7fac
5 changed files with 40 additions and 0 deletions

View File

@@ -216,6 +216,22 @@ class TemplateTestCase(ZulipTestCase):
self.assertEqual(content_sans_whitespace,
'header<h1id="hello">Hello!</h1><p>Thisissome<em>boldtext</em>.</p>footer')
def test_encoded_unicode_decimals_in_markdown_template(self) -> None:
template = get_template("tests/test_unicode_decimals.html")
context = {'unescape_rendered_html': False}
content = template.render(context)
content_sans_whitespace = content.replace(" ", "").replace('\n', '')
self.assertEqual(content_sans_whitespace,
'header<p>&#123;&#125;</p>footer')
context = {'unescape_rendered_html': True}
content = template.render(context)
content_sans_whitespace = content.replace(" ", "").replace('\n', '')
self.assertEqual(content_sans_whitespace,
'header<p>{}</p>footer')
def test_markdown_nested_code_blocks(self) -> None:
template = get_template("tests/test_markdown.html")
context = {