Merge pull request #3450 from alphagov/non-ascii-metadata

Non ascii metadata
This commit is contained in:
David McDonald
2020-05-19 11:31:26 +01:00
committed by GitHub
4 changed files with 62 additions and 33 deletions

View File

@@ -1,7 +1,6 @@
import base64
import itertools
import json
import urllib
import uuid
from datetime import datetime
from functools import partial
@@ -255,14 +254,12 @@ def _get_error_from_upload_form(form_errors):
def format_recipient(address):
'''
To format the recipient we need to:
- decode, address is url encoded
- remove new line characters
- remove whitespace around the lines
- join the address lines, separated by a comma
'''
if not address:
return address
address = urllib.parse.unquote(address)
stripped_address_lines_no_trailing_commas = [
line.lstrip().rstrip(' ,')
for line in address.splitlines() if line