From 613363cccc20f9df660e85d589c4fc3562638444 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 27 Sep 2016 20:27:05 +0000 Subject: [PATCH] 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 --- ietf/submit/views.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ietf/submit/views.py b/ietf/submit/views.py index 672dad730..ffb21cc73 100644 --- a/ietf/submit/views.py +++ b/ietf/submit/views.py @@ -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)