Skip to content

Commit 22e0d39

Browse files
committed
Fixed an issue where text file charset information would be overwritten on upload of multiple files for a draft. Fixes issue ietf-tools#2768.
- Legacy-Id: 16626
1 parent a6f4e87 commit 22e0d39

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

ietf/submit/forms.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, request, *args, **kwargs):
6363
self.authors = []
6464
self.parsed_draft = None
6565
self.file_types = []
66+
self.file_info = {} # indexed by file field name, e.g., 'txt', 'xml', ...
6667
# No code currently (14 Sep 2017) uses this class directly; it is
6768
# only used through its subclasses. The two assignments below are
6869
# set to trigger an exception if it is used directly only to make
@@ -117,9 +118,9 @@ def clean_file(self, field_name, parser_class):
117118
if not f:
118119
return f
119120

120-
self.parsed_info = parser_class(f).critical_parse()
121-
if self.parsed_info.errors:
122-
raise forms.ValidationError(self.parsed_info.errors)
121+
self.file_info[field_name] = parser_class(f).critical_parse()
122+
if self.file_info[field_name].errors:
123+
raise forms.ValidationError(self.file_info[field_name].errors)
123124

124125
return f
125126

@@ -224,7 +225,7 @@ def clean(self):
224225
bytes = txt_file.read()
225226
txt_file.seek(0)
226227
try:
227-
text = bytes.decode(self.parsed_info.charset)
228+
text = bytes.decode(self.file_info['txt'].charset)
228229
except (UnicodeDecodeError, LookupError) as e:
229230
raise forms.ValidationError('Failed decoding the uploaded file: "%s"' % str(e))
230231
#

0 commit comments

Comments
 (0)