From 1bced6e46bb4418d63fb28659b24319362bc9e8c Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Mon, 11 May 2015 11:23:56 +0000 Subject: [PATCH] Tweaked the missing id submission revision message to work also with non-ascii characters in the draft name. Changed the disallowed character error message to be more useful by providing the found document name and byte codes for the disallowed characters. - Legacy-Id: 9610 --- ietf/submit/parsers/plain_parser.py | 6 +++--- ietf/templates/bootstrap3/field_help_text_and_errors.html | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 ietf/templates/bootstrap3/field_help_text_and_errors.html diff --git a/ietf/submit/parsers/plain_parser.py b/ietf/submit/parsers/plain_parser.py index 2c1656e9f..8ad6c4719 100644 --- a/ietf/submit/parsers/plain_parser.py +++ b/ietf/submit/parsers/plain_parser.py @@ -60,16 +60,16 @@ class PlainParser(FileParser): extra_chars = re.sub('[0-9a-z\-]', '', name) if extra_chars: if len(extra_chars) == 1: - self.parsed_info.add_error((u'The name contains a disallowed character: %s ' % (', '.join(set(extra_chars))).decode('ascii','replace')) + + self.parsed_info.add_error((u'The document name on the first page, "%s", contains a disallowed character with byte code: %s ' % (name.decode('utf-8','replace'), ord(extra_chars[0]))) + u'(see https://www.ietf.org/id-info/guidelines.html#naming for details).') else: - self.parsed_info.add_error((u'The name contains disallowed characters: %s ' % (', '.join(set(extra_chars))).decode('ascii','replace')) + + self.parsed_info.add_error((u'The document name on the first page, "%s", contains disallowed characters with byte codes: %s ' % (name.decode('utf-8','replace'), (', '.join([ str(ord(c)) for c in extra_chars] )))) + u'(see https://www.ietf.org/id-info/guidelines.html#naming for details).') match_revision = revisionre.match(name) if match_revision: self.parsed_info.metadata.rev = match_revision.group(1) else: - self.parsed_info.add_error(u'The name found on the first page of the document does not contain a revision: "%s"' % (name,)) + self.parsed_info.add_error(u'The name found on the first page of the document does not contain a revision: "%s"' % (name.decode('utf-8','replace'),)) name = re.sub('-\d+$', '', name) self.parsed_info.metadata.name = name return diff --git a/ietf/templates/bootstrap3/field_help_text_and_errors.html b/ietf/templates/bootstrap3/field_help_text_and_errors.html new file mode 100644 index 000000000..1cf54c9ba --- /dev/null +++ b/ietf/templates/bootstrap3/field_help_text_and_errors.html @@ -0,0 +1,2 @@ +
{% for item in help_text_and_errors %} {{ item }}
{% endfor %}
+