Try various ways of handling non-ascii names/emails in draft submissions, in order to get past the early processing to the point where we run idnits and can flag non-ascii content, instead of failing with a server 500 error.

- Legacy-Id: 12053
This commit is contained in:
Henrik Levkowetz 2016-09-27 20:27:05 +00:00
parent f6ffc1ca10
commit 613363cccc

View file

@ -93,7 +93,26 @@ def upload_submission(request):
email = ""
if email:
line += u" <%s>" % email
# Try various ways of handling name and email, in order to avoid
# triggering a 500 error here. If the document contains non-ascii
# characters, it will be flagged later by the idnits check.
try:
line += u" <%s>" % email
except UnicodeDecodeError:
try:
line = line.decode('utf-8')
email = email.decode('utf-8')
line += u" <%s>" % email
except UnicodeDecodeError:
try:
line = line.decode('latin-1')
email = email.decode('latin-1')
line += u" <%s>" % email
except UnicodeDecodeError:
try:
line += " <%s>" % email
except UnicodeDecodeError:
pass
authors.append(line)