diff --git a/boards/forms/__init__.py b/boards/forms/__init__.py --- a/boards/forms/__init__.py +++ b/boards/forms/__init__.py @@ -296,18 +296,13 @@ class PostForm(NeboardForm): files = [] max_file_count = board_settings.get_int(SECTION_FORMS, 'MaxFileCount') - if type(inputs) == list: - if len(inputs) > max_file_count: - raise forms.ValidationError(ERROR_MANY_FILES) - for file in inputs: - files.append(self._clean_file_file(file)) - elif inputs: - inputs = inputs.replace('\r\n', '\n') - url_list = inputs.split('\n') - if len(url_list) > max_file_count: - raise forms.ValidationError(ERROR_MANY_FILES) - for url in url_list: - files.append(self._clean_file_url(url)) + if len(inputs) > max_file_count: + raise forms.ValidationError(ERROR_MANY_FILES) + for input in inputs: + if isinstance(input, UploadedFile): + files.append(self._clean_file_file(input)) + else: + files.append(self._clean_file_url(input)) return files diff --git a/boards/forms/fields.py b/boards/forms/fields.py --- a/boards/forms/fields.py +++ b/boards/forms/fields.py @@ -78,6 +78,13 @@ class UrlFileField(forms.MultiValueField require_all_fields=False, *args, **kwargs) def compress(self, data_list): - if data_list and len(data_list) >= 2: - return data_list[0] or data_list[1] + all_data = [] + for data in data_list: + if type(data) == list: + all_data += data + elif type(data) == str: + input = data.replace('\r\n', '\n') + url_list = input.split('\n') + all_data += url_list + return all_data