mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #26644 -- Allowed wrapping NamedTemporaryFile with File.
914c72be2a
introduced a regression that
causes saving a NamedTemporaryFile in a FileField to raise a
SuspiciousFileOperation. To remedy this, if a File has an absolute
path as a filename, use only the basename as the filename.
This commit is contained in:
parent
fa654da613
commit
1b407050dd
3 changed files with 18 additions and 0 deletions
|
@ -26,6 +26,12 @@ else:
|
|||
|
||||
|
||||
class FileTests(unittest.TestCase):
|
||||
|
||||
def test_file_truncates_namedtemporaryfile_name(self):
|
||||
named_file = NamedTemporaryFile()
|
||||
f = File(named_file)
|
||||
self.assertEqual(f.name, os.path.basename(named_file.name))
|
||||
|
||||
def test_unicode_uploadedfile_name(self):
|
||||
uf = UploadedFile(name='¿Cómo?', content_type='text')
|
||||
self.assertIs(type(repr(uf)), str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue