Stop escaping special characters in inbound

At least one of our providers gives us messages with special characters
escaped, ie a newline comes through as `\n`, not a literal newline. We
shouldn’t be showing these backslashes to any of our users.

Python has built in codecs for dealing with encoding/decoding of
strings – see
https://docs.python.org/3/library/codecs.html#text-encodings
for details. Using these builtins is safer than trying to do anything
regex or parsing-based.
This commit is contained in:
Chris Hill-Scott
2017-11-06 12:36:26 +00:00
parent fed4275403
commit f6950ae987
5 changed files with 66 additions and 1 deletions

View File

@@ -172,6 +172,25 @@ def test_inbox_showing_inbound_messages(
)
def test_inbox_handles_escaped_characters(
client_request,
service_one,
mock_get_inbound_sms_with_special_characters,
):
service_one['permissions'] = ['inbound_sms']
page = client_request.get('main.inbox', service_id=SERVICE_ONE_ID)
assert normalize_spaces(
str(page.select_one('tbody tr .file-list-hint'))
) == (
"<span class=\"file-list-hint\">"
"the first line's content the second line's content"
"</span>"
)
def test_empty_inbox(
logged_in_client,
service_one,