django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.73k stars 574 forks source link

Copy file but leave empty suffix #1338

Closed bachvtuan closed 12 months ago

bachvtuan commented 1 year ago

I tried to copy file and leave empty suffix and get this error:

File "/home/acme/venv/lib/python3.8/site-packages/filer/admin/folderadmin.py", line 562, in response_action
    response = func(self, request, files_queryset, folders_queryset)
  File "/home/acme/venv/lib/python3.8/site-packages/filer/admin/folderadmin.py", line 1092, in copy_files_and_folders
    if form.is_valid():
  File "/home/acme/venv/lib/python3.8/site-packages/django/forms/forms.py", line 201, in is_valid
    return self.is_bound and not self.errors
  File "/home/acme/venv/lib/python3.8/site-packages/django/forms/forms.py", line 196, in errors
    self.full_clean()
  File "/home/acme/venv/lib/python3.8/site-packages/django/forms/forms.py", line 433, in full_clean
    self._clean_fields()
  File "/home/acme/venv/lib/python3.8/site-packages/django/forms/forms.py", line 448, in _clean_fields
    value = getattr(self, "clean_%s" % name)()
  File "/home/acme/venv/lib/python3.8/site-packages/filer/admin/forms.py", line 29, in clean_suffix
    valid = get_valid_filename(self.cleaned_data['suffix'])
  File "/home/acme/venv/lib/python3.8/site-packages/filer/utils/files.py", line 131, in get_valid_filename
    s = get_valid_filename_django(s)
  File "/home/acme/venv/lib/python3.8/site-packages/django/utils/functional.py", line 246, in wrapper
    return func(*args, **kwargs)
  File "/home/acme/venv/lib/python3.8/site-packages/django/utils/text.py", line 249, in get_valid_filename
    raise SuspiciousFileOperation("Could not derive file name from '%s'" % name)
django.core.exceptions.SuspiciousFileOperation: Could not derive file name from ''

Using packages:

The suffix is not required but leave as empty get this error, what do you think about this error?

stale[bot] commented 12 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fsbraun commented 12 months ago

@bachvtuan Empty suffices are not supported. Something the forms should validate.

fsbraun commented 12 months ago

Sorry for the confusion: Empty suffices need to be supported (as opposed to empty extensions). This PR corrects the form validation: #1386

fsbraun commented 12 months ago

Now fixed and released. Thank you, @bachvtuan, for reporting this!