Skip to content

Commit a32b121

Browse files
committed
Changed some instances of error strings from ascii to unicode in order to avoid problems with unicode error messages, such as the file size indications generated by django.template.defaultfilters.filesizeformat().
- Legacy-Id: 11220
1 parent a15d0ec commit a32b121

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

ietf/submit/parsers/base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,25 @@ def parse_invalid_chars_in_filename(self):
6262
regexp = re.compile(r'&|\|\/|;|\*|\s|\$')
6363
chars = regexp.findall(name)
6464
if chars:
65-
self.parsed_info.add_error('Invalid characters were found in the name of the file which was just submitted: %s' % ', '.join(set(chars)))
65+
self.parsed_info.add_error(u'Invalid characters were found in the name of the file which was just submitted: %s' % ', '.join(set(chars)))
6666

6767
def parse_max_size(self):
6868
max_size = settings.IDSUBMIT_MAX_DRAFT_SIZE[self.ext]
6969
if self.fd.size > max_size:
70-
self.parsed_info.add_error('File size is larger than the permitted maximum of %s' % filesizeformat(max_size))
70+
s = filesizeformat(max_size)
71+
debug.traceback()
72+
debug.type('s')
73+
debug.show('s')
74+
self.parsed_info.add_error(u'File size is larger than the permitted maximum of %s' % filesizeformat(max_size))
7175
self.parsed_info.metadata.file_size = self.fd.size
7276

7377
def parse_filename_extension(self):
7478
if not self.fd.name.lower().endswith('.'+self.ext):
75-
self.parsed_info.add_error('Expected the %s file to have extension ".%s", found the name "%s"' % (self.ext.upper(), self.ext, self.fd.name))
79+
self.parsed_info.add_error(u'Expected the %s file to have extension ".%s", found the name "%s"' % (self.ext.upper(), self.ext, self.fd.name))
7680

7781
def parse_file_type(self):
7882
self.fd.file.seek(0)
7983
content = self.fd.file.read(4096)
8084
mimetype = magic.from_buffer(content, mime=True)
8185
if not mimetype == self.mimetype:
82-
self.parsed_info.add_error('Expected an %s file of type "%s", found one of type "%s"' % (self.ext.upper(), self.mimetype, mimetype))
86+
self.parsed_info.add_error(u'Expected an %s file of type "%s", found one of type "%s"' % (self.ext.upper(), self.mimetype, mimetype))

ietf/utils/bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class SeparateErrorsFromHelpTextFieldRenderer(bootstrap3.renderers.FieldRenderer):
44
def append_to_field(self, html):
55
if self.field_help:
6-
html += '<div class="help-block">{}</div>'.format(self.field_help)
6+
html += u'<div class="help-block">{}</div>'.format(self.field_help)
77
for e in self.field_errors:
8-
html += '<div class="alert alert-danger">{}</div>'.format(e)
8+
html += u'<div class="alert alert-danger">{}</div>'.format(e)
99
return html

0 commit comments

Comments
 (0)