mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-05 23:08:25 -04: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:
@@ -188,6 +188,14 @@ def sample_template_with_placeholders(notify_db, notify_db_session):
|
||||
return sample_template(notify_db, notify_db_session, content="Hello (( Name))\nYour thing is due soon")
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_sms_template_with_html(notify_db, notify_db_session):
|
||||
# deliberate space and title case in placeholder
|
||||
return sample_template(notify_db, notify_db_session, content=(
|
||||
"Hello (( Name))\nHere is <em>some HTML</em> & entities"
|
||||
))
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_email_template(
|
||||
notify_db,
|
||||
@@ -224,6 +232,15 @@ def sample_email_template_with_placeholders(notify_db, notify_db_session):
|
||||
subject_line="((name))")
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_email_template_with_html(notify_db, notify_db_session):
|
||||
return sample_email_template(
|
||||
notify_db,
|
||||
notify_db_session,
|
||||
content="Hello ((name))\nThis is an email from GOV.UK with <em>some HTML</em>",
|
||||
subject_line="((name)) <em>some HTML</em>")
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def sample_api_key(notify_db,
|
||||
notify_db_session,
|
||||
|
||||
Reference in New Issue
Block a user