mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Don’t strip HTML when saving templates
Right now we strip HTML from templates at the point of saving them. This also converts stuff like ampersands to their entity form (eg &) and this is what we save in the database. This is a bad idea when you’re sending a text message or a letter, in which an HTML entity makes no sense. But we still need to encode HTML in the body of HTML emails. The right place to do this is when rendering the templates. The code to do this is now in utils. So this commit: - pull in this new utils code - removes the old - adds some integration tests to make sure that everything is working as expected (more thorough unit tests are happening in utils)
This commit is contained in:
@@ -37,7 +37,7 @@ def test_should_create_a_new_template_for_a_service(
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp['data']['name'] == 'my template'
|
||||
assert json_resp['data']['template_type'] == template_type
|
||||
assert json_resp['data']['content'] == 'template content'
|
||||
assert json_resp['data']['content'] == 'template <b>content</b>'
|
||||
assert json_resp['data']['service'] == str(sample_service.id)
|
||||
assert json_resp['data']['id']
|
||||
assert json_resp['data']['version'] == 1
|
||||
@@ -153,7 +153,9 @@ def test_update_should_update_a_template(client, sample_user, sample_template):
|
||||
|
||||
assert update_response.status_code == 200
|
||||
update_json_resp = json.loads(update_response.get_data(as_text=True))
|
||||
assert update_json_resp['data']['content'] == 'my template has new content alert("foo")'
|
||||
assert update_json_resp['data']['content'] == (
|
||||
'my template has new content <script type="text/javascript">alert("foo")</script>'
|
||||
)
|
||||
assert update_json_resp['data']['name'] == sample_template.name
|
||||
assert update_json_resp['data']['template_type'] == sample_template.template_type
|
||||
assert update_json_resp['data']['version'] == 2
|
||||
|
||||
Reference in New Issue
Block a user